I always lock myself in my room when I face big problems like losing someone I love, work and even losing money while gambling (my family understands my behavior). usually after 8 to 9 days, all my feelings will return to normal and start to get better. I really have a hard time hiding my behavior when I'm at a loss and it still happens to this day.
I highly suggest that you go see a doctor or a psychiatrist as those are the signs of some mental health issues. Though every person has their respective coping mechanism, what you exhibit is something strange and unusual that requires medical attention. Since you also mentioned that you find difficulty in coping for your losses, then I think it is better if you just avoid gambling at all.
In general, every person has their respective methods in order to cope for their loss. While others may exhibit normal behaviours, other have difficulty in coping and accepting defeat. If that is the case, then preventing and avoiding gambling would be the better method in order to address and prevent these issues.