Set yourself a time and money limit and stick to it.
I'm sure every poker player has steamed and gone on tilt at some point. I started playing on 888
this year, got off to good start, had 1 terrible day and went bust. Put on another $20, got it to over $100 and came withing a whisker of going bust but won the last hand to salvage $28 and forced myself to stop. After that I adopted a strict 3-3-3 limit, If I win $3, lose $3 or play 3 hours I stop, no matter what (I play .01/.02 SNAP where you can only bring $1 to the table so $3 is good enough for a recreation player like me). Between that and freerolls
I've worked that $28 up to $184 and there were definitely a couple of nights where I could easily have gone off the rails if I didn't force myself to adhere to the limits.
Obviously each player should set their limits to the stakes they play and their normal playing time, the important thing is to set a limit and stick to it.