SPOILER ALERT: Do not read any further if you don't know want to know the stunning plot twist on Sunday's episode of "The Good Wife." ...

"Shots fired in Cook County Courthouse."

Those words, uttered by a petrified Kalinda Sharma (Archie Panjabi), were the first indication that something had gone horribly wrong during Sunday night's episode of "The Good Wife."

Soon, viewers learned that Will Gardner (Josh Charles) was gunned down by his deranged client, Jeffrey Grant (Hunter Parrish), in the middle of a court proceeding. And moments later, a tearful Kalinda and Diane Lockhart (Christine Baranski) gazed down at his lifeless body on a bloody gurney.

Josh Charles as Will Gardner in ’The Good Wife’ episode, ’Dramatics, Your Honor’ televised on Sunday, March 23, 2014. Charles
Josh Charles as Will Gardner in 'The Good Wife' episode, 'Dramatics, Your Honor' televised on Sunday, March 23, 2014. Charles character was killed in a courtroom shooting. (CBS)

And with that shocking, out-of-nowhere death, one of the show's main stars, and a beloved character, was gone.

Reaction on social media was immediate:

"Experiencing the 5 stages of grief for the death of a TV character. Currently still in "bargaining,'" tweeted one fan.

"I can't handle what just happened on #thegoodwife. I need a support group," wrote another.

The stunning plot twist was one of the TV season's best-kept secrets. Last spring, Josh Charles signed a deal to return to "The Good Wife" for the show's current fifth season, but indicated to executive producers Robert and Michelle King that he was ready to step away from the show when his contract was up.

That gave the Kings and their writers plenty of time to plot Charles' shocking exit, which evoked memories of the sad death blow delivered to Matthew Crawley (Dan Stevens) on "Downton Abbey."

It has been a season of dramatic narrative upheaval for "The Good Wife," which deployed a major reset when Alicia (Julianna Margulies) left Lockhart Gardner -- a dynamic that put Alicia in direct conflict with Will, her former lover. It will be intriguing to see how the show handles its latest hairpin turn.

After the show aired on the East Coast, the Kings tweeted: "Every moment has been a pleasure. We'll more than miss you."

Charles responded: "The pleasure has been all mine. I've learned so much working with both of you & I'm in awe of your talent & storytelling."

Contact Chuck Barney at Facebook.com/BayAreaNewsGroup.ChuckBarney, or Twitter.com/chuckbarney