the-good-wifeUPDATED: CBSThe Good Wife already went through a major reset at the beginning of the season when Alicia (Julianna Margulies) left Lockhart Gardner, finding herself locking horns with her former boss, friend (and on-and-off flame) Will Gardner (Josh Charles). But that was just a little ripple compared to the shock wave that hit the show tonight. Here is the story behind the stunner, with The Good Wife creators/showrunners Michelle and Robert King, who wrote the episode, discussing the major exit, its impact on the show and what lies ahead. Warning for DVR viewers — this story contains a major spoiler. Proceed with caution.

The Good Wife Josh Charles spoilerTonight’s episode of The Good Wife featured the abrupt exit of original cast member and series male lead Josh Charles, whose character Will Gardner was shot dead in the courtroom by a deranged client. While the shocking development had been kept under wraps and came as a surprise to viewers, it had been in the works since last spring. “Josh Charles approached us almost a year ago about wanting to leave the series,” Michelle and Robert King said. Charles was looking to leave the series at the end of last season, the show’s fourth, when his contract was up. After playing the character for four years, the actor indicated he was ready to move on.

Related: ‘The Good Wife’ Creators Pen Letter To Fans After Shocking Plot Twist

Charles, whose role on The Good Wife has earned him an Emmy and Golden Globe nominations, comes from a feature background and his only previous regular series gig was on ABC’s Sports Night, which ran for two seasons. He hadn’t entered a standard, long-term contract for The Good Wife, which gave him an out last May. The Good Wife star Margulies, who also is a producer on the series, was told of Charles’ decision right away. “She was instrumental in convincing Josh to stay for a fifth season,” the Kings said. Charles agreed to stay on for another season with a new short-term deal. That gave the series’ writers a chance to plan his exit as one of the major plot twists in year five. By the end of last season, the entire main Good Wife cast had been informed of Charles’ pending departure, so they knew going into Season 5 that it would be their last with Charles. “Their reaction was understanding,” the Kings said. “It’s a very collegial and professional cast, and they understand an actor leaving because he wants to challenge himself. It helped that Josh was directing two episodes this season, and one of the episodes we specifically arranged for after he left the show so the band-aid wouldn’t be completely ripped off.” (Watch scenes from tonight’s dramatic episode with reactions the Kings, Charles, Margulies and other cast members in the video below)

Related: CBS Showrunners Talk Killing Off Characters

In writing Charles off, The Good Wife followed a similar path Downton Abbey took with leading man Dan Stevens whose character suffered a sudden tragic death when the actor opted the leave the show after three seasons. The Good Wife producers considered alternative scenarios that would’ve kept Will alive in the vein of what happened on Margulies’ previous hit series ER where the actor playing her love interest, George Clooney, also left in the second part of Season 5. His character was not killed off but sent off to Seattle and later reunited with Marguies in her final episode on the medical drama. “We strongly considered the ‘Sending Will to Seattle’ route,” the Kings said. “(Will) could get disbarred or run off to Borneo to do good works. But it didn’t do much for us dramatically. It was the softer blow, but at a certain point the show wasn’t looking for the softer blow. We wanted there to be a painful turning point in Alicia’s life. Also there are major story hubs you’re always looking for in building a season: points in the narrative where it changes every character’s trajectory. It keeps the show from feeling stale. Earlier this season that turning point was Alicia and Cary leaving the firm and starting their own offices. This is the second hub. The death of Will will impact the show down to its core, it spins every character off in a new direction. And we were excited to see where everybody landed.”

Related: Q&A: ‘The Good Wife’s Josh Charles

Dramatics, Your HonorUnderstandably, the biggest impact will be on Alicia. “She will find herself shattered: not just because she’s lost her sometimes-lover but also because Will left her on such ambiguous terms. That’s what the next episode is about: sudden death being irredeemable. Whatever your last moment was with a loved one, it can never be changed.”

As for losing our original male lead, “the show has a strong ensemble cast, one we buttressed with the arrival of Matthew Goode (as a new prosecutor) and the return of (popular recurring guest stars) Michael J. Fox for four episodes and of Dylan Baker,” the Kings said. And, following Charles’ emotionally charged exit, The Good Wife plans to lighten things up a bit. “The show has always had a comic and a tragic side. In the coming episodes we’ll see more of the comic,” the Kings said. “And we’ve also built in continuing stories—like the NSA plotline—that will keep asserting themselves so that there will always be the comfort of the familiar.” Michelle and Robert King have a lot to plan ahead: The Good Wife was recently renewed for a sixth season.

The Kings and Charles had one final exchange tonight. “Every moment has been a pleasure. We’ll more than miss you,” the showrunners tweeted to Charles after the end of the episode. Responded Charles, “The pleasure has been all mine. I’ve learned so much working with both of you & I’m in awe of your talent & storytelling.”