This is a tough one, friend. Many of us struggle with it to one degree or another, and, as you've experienced, it can get really intense/bad when we are feeling anxious, overwhelmed, or frustrated. Talking to a "safe" person can help when you just really need to vent -- otherwise, how about writing a letter in which you just unleash all your feelings and get very explicit about how upset or hurt you are? It helps some people (including me) a lot.
What I find harder is someone "leading" me into negative remarks about someone behind the subject's back -- they said something about how the subject has upset them or has xyz negative trait -- and before I knew it, there I was, expounding on what I thought was abhorrent about that person's behaviour.

Auuggghhh!
Being super-aware of it helps -- but not always enough. Letting it out in other ways is best, I feel; but it's tough no doubt.
Best of luck.
Chyia, imperfectly fighting that battle as well