On last night’s episode of “The Good Wife“–spoiler alert!–Gardner, the character played by actor Josh Charles, was killed in a courtroom shooting. The fatality took many “Good Wife” fans by surprise, in part because there was very little buildup. The death happened suddenly, just like tragedies sometimes happen in real life. And real life–and real death–used to be the last thing people expected from TV dramas.

In recent weeks and months, killing major characters has become a thing on television. Of course, back in the day, TV had its share of deaths. In 1975 on “M*A*S*H,” the Henry Blake character, beloved by nearly everyone, was shot down over the Sea of Japan. In 1980 on the “All in the Family” spinoff “Archie Bunker’s Place,” the Edith Bunker character, beloved by nearly everyone, died of a stroke.

Just this week on “Scandal”–spoiler alert!–the James Novak character was the victim of a hit. “House of Cards” kicked off the season with the surprising slaying of a major character, and the even more surprising use of a passing train as the murder weapon. And every other week on “Game of Thrones” someone gets killed, and judging from the books, the body count will continue to grow, Red Wedding-style.

Great writers have to be heartless. Killing off a character in a swift, surgical line in a book or screenplay can deliver an emotional jolt. It lets the reader or viewer know that nobody is safe. Death on TV is really about how much life a character had. The sense of loss viewers feel is a measure of how much they care about the work.

“The Good Wife” cocreators Robert and Michelle King wrote in an open letter that “when faced with the gut punch of Josh’s decision, made over a year ago, to move on to other creative endeavors, we had a major choice to make.” They said there was always a tragic element in the relationship between Gardner and Alicia Florrick, and “the brutal honesty and reality of death speaks to the truth and tragedy of bad timing for these two characters.”

“Finally, we chose the tragic route for Will’s send-off for personal reasons,” they wrote. “We’ve all experienced the sudden death of a loved one in our lives. It’s terrifying how a perfectly normal and sunny day can suddenly explode with tragedy. Television, in our opinion, doesn’t deal with this enough: the irredeemability of death.”

Killing a major character can be a way to refresh a tired show, to propel a new plot line, or a desperate ploy to get a show trending on social networks.

Gardner was a good character. His exit disentangles “The Good Wife” from some old storylines. It also cuts off fans from a character they had become intimately familiar with. If fans feel that the death is a manipulative ratings grab, the whole thing could backfire, and instead of making the show seem more realistic, the death could expose the puppeteering behind the plot twists.

Fans turn to movies for drama, but they turn to long running TV shows for something else as well–familiarity. A TV series can be a kind of comfort food, a televised hamburger, and week after week we sit down for a TV dinner with characters we know and sometimes love. We want drama, but we don’t want too much. That’s why Capt. Kirk always beams down to hostile alien planets with a bunch of unnamed crew members. They get killed, he survives.

Immediately after tonight’s “The Good Wife,” #TheGoodWife was trending on Twitter. Let’s see if Gardner’s death ends up being worth more than a hashtag.