But I did something else. I took the opportunity to also learn:
Stand up. Some of the bad bosses are like bullies that never grow up. They try to intimidate you because they feel they can. Don't let them get away with it. The trick is not to respond in kind, because you only escalate. But calmly state the facts.
I had a manager who used to constantly come into my office (even during lunch), and interrupt me with a new task. I would take it in, and add to my "catch list". I'd then go back with priorities we had agreed to earlier. And then, either (a) adjust my priorities to accommodate the new task or (b) get my manager to agree that the existing priority list was the correct one. This tip is from Patty Azzerello's blog of "Catch vs. Do". Take a look at her comments on setting "Ruthless Priorities" and sticking to them.
Change what needs to be changed. If you take the "sting" out of their criticism, there's usually a kernel of truth. Self awareness is critical to help you grow; and tough bosses shine the spot light on flaws you need to correct. If they are saying it, chances are others are too - just not as directly.
One of my managers told me; in effect, "I wasn't fit to be an engineer". It didn't make sense at first; my grad and undergrad degrees said otherwise. Going deeper, I understood. "Don't pursue a career in program management, but you can excel in product management". It was the right call, and I am glad I switched. I wouldn't have changed if it weren't for that pivotal moment.
Another manager was always picky about my communication. I mean even nits like commas. I realized the importance of clear structured communication and invested in learning (a) Precision Questioning and Answering and (b) the Minto Pyramid. Both turned out very helpful - and still do.
Give feedback with finesse. In the case of my bad bosses, I learned what not to do. When they gave critical feedback, it was harsh. It made me feel less valued. I learned to bounce back, but I never want to do that to another human.
So next time you have a boss that's causing you grief; think. Are you going to leave or stay? Either way, don't forget to learn.