Think of it like alcohol
Once I have calmed down from a bad streak, I don't care about losing: my goal is to get as many bets out as possible at the right time and within the constraints dictated by risk of ruin.
That said, I will stop if I think anger or frustration is affecting my concentration. After Wonging in to a juicy shoe and then losing a healthy number of max bets, including several double downs, I try to put thoughts of the beating aside and ask myself "Is this affecting my concentration?
If the answer is Yes, or even Maybe, I step away for a half an hour.
It's much the same as with alcohol. If you suspect it could be affecting your counting, you should stop playing until you're sober.
This is not about luck. It's about watching your emotions, and admitting when they're getting to you.
I don't have a problem with steaming - I can soldier on for hours in the face of any bad beat - but short-term disbelief at bad breaks, and sometimes extremely good ones, affects my ability to keep the count and make the right plays.