While I'm not a huge fan of it, it sounds like you need to set a stop loss limit. Basically, you come up with a set amount you are willing to lose, and once you hit that amount you stop playing. When I began playing, over a decade ago, I would quit if I lost 1 full buy-in (limit game).
Also, if you are quitting while you're ahead, that's a bad idea. You could be up from luck, but you could also be winning because you're focused, or just in "the zone".
When you're winning you want to keep playing.