Buddha said, when you’re angry, count to ten. When you’re still angry, count another ten.
Seriously though, most of the time getting mad isn’t worth it. It makes you look bad, makes you inefficient and at the same time makes you and other people feel bad. It’s overall, if we are thinking logically, a negative condition/ situation to be in. Getting angry/ mad brings nothing to the table.
Try to think like this, every time you’re about to get mad: is getting mad brings anything? Would it change the situation? Can the things already happened be undone? Do I have other choices other than accepting it and fixing the situation? What should I do next? Once you can think like that, calmly, I am sure that you can stop getting mad.
The problem is, most of the time/ very often, you’re not even aware that you’re angry/ getting angry, and you let your emotions take control of you. That’s why you have to train yourself to be aware of your thoughts/ feelings most of the time, and in that way you can react accordingly, consciously, doing what would be your best action/ most logical action. Some people can achieve this through practicing meditation. I’m sure, once you are more aware on what and how you feel most of the time, you would be able to control your actions/ emotions much better.
I’m a doctor so I know how dying people act. It’s unrealistic that a dying person, like a couple of seconds before he/ she’s completely gone, to talk much sense. They speak random stuff, disoriented, or in a complete panic state until they lost their consciousness and then die short after.