This article from the Harvard Business Review uses the movie Horrible Bosses to illustrate that sometimes you can't get away from a bad boss, though sometimes, unlike the movie, it's not a funny situation. As a leader you have to put safeguards in place to stop really bad bosses from pushing away your valuable staff and making the work environment horrible. Leaders can do this by having regular objective measurements for performance reviews, policing managers for harassment or constant disagreements, etc. However, the best way is to make your teams work with other teams in the company regularly. This reduces the impact of a single bad egg within a company.