If you spend enough time in the business world, there will inevitably be times when you need to stand up for yourself and do what’s best for you, instead of just marching like a good corporate soldier.

But if you burn bridges and shoot yourself in the foot, you’ve served neither the company’s nor your own best interest. It’s lose-lose … like Ted Cruz’s speech at the Republican National Convention last week.

By failing to endorse Donald Trump as he had publicly pledged to do, the Texas senator drove a wedge right through a party that desperately needs to unite behind Donald Trump if it hopes to defeat Hillary Clinton in November. Cruz hurt his own party’s chances so that, if Trump loses, he can say I told you so and come to the rescue down the road.

Of course, the flaw in the strategy is its transparency. By putting himself ahead of the party -- and doing it so publicly that nobody can possibly misinterpret his motives -- he left no doubt about his character as a leader: that he’s selfish, disloyal and can’t be counted on to do the right thing when everything is on the line.

Related: 4 Lessons Every Entrepreneur Can Learn From Donald Trump

Best-selling author, syndicated columnist and political commentator Charles Krauthammer called Cruz's 23-minutes speech, “The longest suicide note in American political history.” He’s absolutely right. Cruz burned a bridge and shot himself in the foot. The irony is, it served neither him nor the party. It was a big fat lose-lose.

What should he have done? If for whatever reason he couldn’t endorse the party’s nominee with a clear conscience, he should have declined to speak. If someone you can’t stand invites you over, you politely decline. You don’t show up and burn down the house. That’s not rocket science -- it’s just common sense.

Meanwhile, Trump had seen the speech hours before Cruz got on stage and still allowed him to deliver it. That’s called taking the high road. That’s what good leaders do. That’s what good employees do. That’s what smart people who want to do what’s best for their company and for themselves do. That’s what Cruz should have done.

The following morning, Cruz made matters worse by saying he did what he did because Trump had insulted his wife and father in the run-up to the nomination. The thing is, political campaigns get ugly. The same is true of the business world. If you can’t handle it, you don’t belong in any leadership position.

Related: 5 Reasons Leaders Behave Badly

I can’t tell you how many times I’ve been passed over for executive jobs and promotions. And some of those situations were not just poorly handled, they were downright ugly. No matter. You don’t have to agree with the decision, but you still have to suck it up and take the high road. You put on your game face, say thank you for the opportunity and wish them luck.

If you lost a bid to be promoted, you do what former Intel CEO Andy Grove used to call “disagree and commit,” meaning you stand behind the decision, right or wrong. That’s what’s best for the company. You can always quit and go somewhere else if you like. Oftentimes, that turns out to be the best outcome for everyone involved.

Likewise, if you lost out for a job at another company, be professional about it, even if the hiring people weren’t. You may run into them elsewhere or find yourself in the running for a different position at the company, someday. You never know. It’s a small world. There’s simply no reason to burn a bridge. It never reflects well on you.

You see, everything happens for a reason. If you take some time and think about it, you can usually take away some lessons from the loss and be the better for it. That’s how you learn, by trial and error. But it only works if you’re honest with yourself and willing to take a good hard look in the mirror.

Related: 4 Signs You Talk Too Much at the Office

If, on the other hand, your reaction is petulant and angry, you’ll never learn a damn thing. You’ll never get anywhere that way. You’ll simply end up like Ted Cruz. Now he’s untouchable. Radioactive. How long will that last? I’m not sure, but when you snub your own party and its candidate for president, people tend to have a pretty long memory.

Don’t screw up your career. Don’t be like Ted Cruz.