Risk is part of the game, coming close to an important victory or losing it by a hair's breadth is a risk you can't ignore.
It's called gambling, you risk a bet and at most the only thing to do for a few days is not to bet anything,
the time to assimilate the loss and psychologically you've calmed down.
There are no magic wands or useful advice in these things, simply keep calm and think: tomorrow will be better!
Yep that's the sad truth. Not much we can do other than try to calm ourselves and not overthink. It's easier said than done though because we can't stop thinking about such losses. It's the close bets that always hurt

because if we lost the bet early on, it doesn't even feel bad. But because we came so close to winning and then lose, it makes us mad.
Usually after such a loss, I go to the casino side and try to get a big win. I think my worst bets have come when I had a close loss and I can't stop thinking about it, leading me to make more rubbish decisions. It hurts even more when you had the chance to cash out but you let it ride and then you lose.