Well, I am going to refer to poker specifically, since I play casino games on an occasional basis, with money that I can afford to lose, and I never exceed the budget that I have foreseen.
As for poker, I could divide the question in two: what is a bad beat and what is a bad session. Bad beads are something you get used to when you've been playing for years. Having more than a 90% chance of winning on the turn and losing on the river happens to me every day, so I'm (most of the time) emotionally neutral.
In bad sessions usually happen several bad beats and coolers and the best way to deal with it is emotionally neutral too, although we are human and sometimes it can affect your mood a little. If that's the case, I make the session shorter. I close earlier, and come back when I'm more rested, to play as emotionally neutral as I can.