The first step is to implement some form of bankroll or budget management. Some reasonable numbers can be to always have at least 100 X the buyin of an MTT, you want to play, 50 X the buyin of a SnG and 30 X the full buyin of a cash game. In this way it will be almost impossible to lose all the money in just a single session or a single day. And if you have a tilt problem, then enforce these rules on yourself by setting playing limits on the site.
On
pokerstars you can set limits individually for cash games, SnGs, tournaments, casino games and sports betting. So if your bankroll or balance in the account is 350$, then set the cash game limit to 10NL, the SnG limit to 5$ and the tournament limit to 3,3$. These can be changed later, but if you want to increase them, it takes 24 hours for the changes to take effect. So you cant chase after losses by suddenly jumping up and starting to play 25$ SnGs or 50NL cash games. If you have a tendency to go in the casino section to recoup losses, then seriously consider setting the casino limit to "dont play".
The second step is to get into a habit of ending your session, if you start to feel tilted. If you play cash games, end the session right away or at least, when the blinds come around again. If you play SnGs or MTTs, then stop buying into more games and concentrate on finish those, you already have running. It can also be a good idea to use some sort of stop-loss system. Like maybe if you lost 10% of your bankroll in a single session, then you are done for the day, even if you dont feel tilted.
The last step is to learn to tilt less. A lot has been written about this subject, but one of the best advices, I have seen, was in a recent post by another forum member. He wrote, that when he suffer a bad beat, then he ask himself, how much this will matter to him next year, next week or even tomorrow? And the answer is always "not at all". So why then care about it now? At the end of the day its just a game, and we are hopefully only playing with money, we can afford to lose. Finally there are books about tilt management. Many people recommend Jared Tendler "the mental game of poker".