I want to share my experience. I was working for a wonderful company, but it had a reputation for the highest HR attrition due to the VP-HR. I used to have nightmares. She used to insult us in front of others, shout wherever she was standing, and find fault with almost all the work we did. I saw at least a dozen HR executives joining and leaving within 9 months. One day, I even stopped going; I had gone into depression. Today, I feel I shouldn't have taken it personally because the company realized it sooner or later and moved her to a different profile. It was a difficult decision as she was one of the pillars of the company. But if I had just stayed a few more months, I would have achieved a few things earlier. It's not that I am not doing well now, but I could have had better exposure at a very early stage of my career.
Advice on Handling a Bad Boss
You must always leave your office within its premises, at least the demotivating thoughts, and consult a senior member from the company before quitting. That should be the last option.