You can better manage your emotions in many ways to avoid acting out in stupidity. Some tips that may help you include:
Acknowledge and accept your emotions as they come.
Take time to assess the situation before responding.
Practice deep breathing and mindfulness exercises to calm down.