Well, have you ever got mad at someone and they got mad at you? The first thing I would say is to change the subject. But people sometimes just say, "That's not what we were talking about, so be quiet!" If that happens, try to explain to him or her, and say that you would like to stop yelling, and that is why you changed the subject.
Now, if you are about to go off and yell at someone, take a few deep breaths and calm down. If you still can't calm down, take a seat. Make up a happy poem in your head and repeat it. Then once you have calmed down, go up to the person, say you're sorry, and explain to them what you were about to tell them.
Just remember, no matter what, just calm down and think about what would be best to do.