When I was studying Ag education one of the first topics that my professor discussed and continued to reinforce during each of his classes was managing student personalities.
We all want to be accommodating and allow students to express themselves, but when we've had enough, then we've really had enough. Therein lies the problem. That moment when you've had enough is your high water mark. Whether you are a new teacher or a veteran teacher struggling with apathy (or even burnout), you may find that you are absorbing more nonsense from your students than is healthy for your mental health. You've set that water mark way too high. You are allowing too much garbage from your students to pool around your feet and slowly rise until it nearly drowns you. Then and only then, do you decide to blow off steam much to the surprise of your students. Quite frankly, you are pretty surprised too when it happens. I suspect there's a good bit of emotion that comes with that release as well. In my opinion, this isn't a healthy habit to develop, but I feel there's an easy fix.
You have to push that high water mark from just below your chin to down somewhere between your knees and ankles. This requires you to recognize the type of garbage you normally internalize instead of dealing with. I firmly agree that you need to pick your battles with students, some nonsense you just let go but the behavior you really disapprove of has to be stomped out early.
Fires are easier to put out when they are small and student behavior is the same way. If bullying behavior is intolerable to you at any level, then recognize the early signs the first few days/weeks of school and jump on it hard. Don't allow the student(s) to build up the inertia (confidence) of getting away with it before you act. If crude jokes or at least inappropriate jokes are on the menu for one student, then redirect them immediately. Jokes in poor taste mutate into inappropriate jokes and one day they'll just turn flat out obscene.
Take some time to discover what really sets you off. What kind of behavior are you allowing but ultimately sends you through the roof? It may be student behavior isn't that bad, but you are a poor organizer and a series of poorly planned events/classes/activities really have you disjointed. It only takes one student having a bad day to trigger the anger you've built up over that last few weeks.
It could be you feel rushed or overwhelmed and that there's no time to accomplish everything your chapter needs. The stress alone from that feeling will suck the life right out of you. One word: delegate. There are tasks that your best students can do for you. It doesn't have to be anything big even delegating the smallest stuff can feel like a huge relief to just not have to do one extra task. All you have to do is manage them. After reading this you say "But it's easier to do it myself than having to check up on them and fix their mistakes." I agree completely, but you have to learn how to delegate better and students have to learn how to listen, follow instructions, pay attention to the task, and review their results based on their instructions they were given. This is a life lesson for you and the student. You'll get better at delegating and they will get better at completing individual tasks like they will do in their first job. Allow yourself to grow and develop this skill and you will find that you've created another method to impact students.
So keep an eye out for what frustrates you and start working on methods to limit that frustration before it boils over into your life. Put out those fires quick and remove those triggers from your everyday life. When you take a few moments to make this part of your life, then you will become a happier person and certainly less stressed than you had been. Good luck!