NEW YORK (AP) — The shocking death of dashing attorney Will Gardner on “The Good Wife” on Sunday’s episode was driven by actor Josh Charles’ desire to leave the CBS drama in its fifth season.

Charles had told the show’s producers that “I was ready for the next chapter of my life, both creatively and personally,” in an interview excerpt provided by CBS on Monday.

In a true surprise for viewers of the show, Gardner was gunned down in a Chicago courtroom by his unhinged client. Gardner was one of the show’s central characters as the former colleague and lover of Alicia Florrick, the “wife” played by series star Julianne Margulies.

The twist will force Margulies’ character to examine all aspects of her life, producers said.

“She’s going to miss the existence of Will,” Margulies said of her character. “He was a powerful aphrodisiac in her life.”

Once the episode had aired, Twitter lit up with astonished, sorrowful and even irate posts.

One viewer called for a group hug, while another issued a plea for a counselor to treat jolted fans. Yet another viewer expressed hope that, as with “Dallas” long ago in revealing Bobby Ewing’s death to be only a dream, “The Good Wife” would find Gardner stepping out of his shower next week, alive and well.

Other viewers vowed never to watch the show again, as payback.

Charles said he appreciated the support of fans, but urged those who are upset to take a step back.

“I understand that there will be audience members who will be upset,” Charles said. “I would just tell them that I guarantee it will continue to be an excellent show. I know I’m going to keep watching it.”

His death and Charles’ decision to exit the show had been well-guarded secrets. Charles, who entered the series with a four-year contract, opted not to re-up when it expired after last season, according to his publicist.

Charles’ past TV work includes the ABC dramedy series “SportsNight” and a season playing a client of therapist Gabriel Byrne on the HBO drama “In Treatment.”

___

Associated Press Television Writer David Bauder contributed to this report.