Utah’s biggest TV star is out of a job. Again.

In one of the most amazing displays of courage network television has ever seen, ABC canceled “Roseanne” — TV’s top-rated show this past season — after Roseanne Barr’s racist tweet about a former adviser to President Barack Obama.

(Photo courtesy of ABC/Image Group LA) Channing Dungey is the president of ABC Entertainment.

Roseanne’s Twitter statement is abhorrent, repugnant and inconsistent with our values, and we have decided to cancel her show,” ABC Entertainment president Channing Dungey said in a prepared statement.

The cancellation came a day after Barr, a Salt Lake City native, tweeted a racist “joke.” In response to a random tweet trying to link former Obama adviser Valerie Jarrett to allegations that the CIA spied on the president of France, Barr tweeted: “muslim brotherhood & planet of the apes had a baby=vj.”

The first half of that is irresponsible, conspiracy-theory drivel, fostered by debunked reports that Jarrett is a Muslim herself who once vowed to make America more Muslim.

The second half of that is the worst kind of racist rant. Barr apologized on Twitter for “making a bad joke about her politics and her looks” but — seriously — she compared an African-American woman to an ape

And — surprise! — ABC fired her, bringing a sudden end to the unexpectedly successful revival of her 1988-97 sitcom.

Whoa. This sort of thing just doesn’t happen.

Although it almost seemed inevitable, right? Barr has a long history of offensive behavior, going back to the early success of her sitcom 30 years ago. And, in this age of social media, you had to figure she’d end up tweeting something so offensive that even the revival’s huge success couldn’t obscure her vile views.

But the cancellation is still a shock.

It’s not that Barr didn’t deserve firing, it’s just that in success, TV stars tend to get away with terrible behavior. Charlie Sheen lasted eight seasons on “Two and a Half Men” despite multiple allegations of abusing women, and he quickly transitioned to a starring role in another sitcom, “Anger Management.”

You have to go back decades to find hit shows that were canceled for reasons that had nothing to do with their ratings. “The Smothers Brothers Comedy Hour” got the ax in 1969 because of Tom and Dick Smothers’ anti-Vietnam War activism; CBS also canceled “The Sonny & Cher Comedy Hour” in 1974 because the duo announced their impending divorce.

And it has long been rumored that CBS canceled “Lou Grant” in 1982 because of the political activism of its star, Edward Asner.

But no network has ever canceled the No. 1 show on TV because of its star’s offensive behavior. Remember, ABC ignored Barr’s homophobic slurs against TV Guide critic Matt Roush during the original run of “Roseanne.”

What Dungey did on Tuesday is not just astonishing, it’s astonishingly courageous. It’s not that easy to do the right thing when TV ratings and ad revenue are involved.