Everybody deserves a period of mourning — which is why, in a startling twist, “Major Crimes” creator James Duff killed off the series’ lead character, LAPD Commander Sharon Raydor (Mary McDonnell), four episodes prior to Tuesday night’s series finale.

“No one wanted the show to end … The people who wrote it, the people who acted in it, the crew, studio [Warner Bros.], everyone — we are all grieving the end of ‘Major Crimes,’” says Duff. “We felt the audience would want to grieve with us and that they would need a shock to help them get to that place.”

That shock would be the dramatic, sudden heart-failure death of Raydor during an intense suspect interrogation in the Dec. 19 episode. The police procedural — which spun off from “The Closer” (starring Kyra Sedgwick) when that series ended in 2012 — planted seeds about Raydor’s life-threatening health issues throughout this sixth and final season. “I have an obligation as a mystery writer to surprise people — and to give them clues. Creatively and professionally, that was the right way to go,” Duff says. “If nothing else, I should get points for daring — and so should Mary.”

Duff notes that many fans objected to the one-two punch of cancellation — announced in October — followed by Raydor’s death, but he makes clear that the former was TNT’s call, not his. “The emotional reactions indicate how engaged people were with the show. I also think people should save some of their anger and rage for the people responsible for taking us off the air,” he says. “It’s not me.”

G.W. Bailey, who’s played crusty, comical Lt. Louie Provenza for 13 years on both “The Closer” and “Major Crimes,” is more direct about the franchise’s end. “There is no question they [TNT] wanted to kill the show. Kevin Reilly didn’t want the show anymore,” Bailey says, referring to the Turner Entertainment chief creative officer who was hired in 2015 to shake up programming on sister networks TNT and TBS.

“Would I like to keyhole certain people? Yes, of course I would,” says Bailey, 73. “Am I going to lose any sleep over Kevin Reilly? I am not.”

Instead of losing sleep himself, Duff wants “to end the show with a bang” that he hopes will satisfy fans. That includes bringing back elusive serial killer Phillip Stroh (Billy Burke), who continues to target Raydor’s adopted son, former hustler Rusty Beck (Graham Patrick Martin), a witness to Stroh’s murderous ways dating back to “The Closer’s” series finale.

Bailey thinks longtime viewers will embrace the outcome. “Let’s put it this way: People who are afraid of Phillip Stroh, Wednesday morning they’ll feel just fine,” he says, laughing. “Ultimately what’s going to transpire is fairly obvious.”

As the Raydor-free finale approaches, Duff heaps praise on McDonnell, whose steely character carried the spinoff and grew on fans, despite starting off on “The Closer” as an adversarial Internal Affairs captain to Sedgwick’s beloved LAPD Deputy Chief Brenda Leigh Johnson.

“She was great throughout and managed a negotiated hairpin turn from villain to hero in a way many other actors would have found impossible,” Duff says. He’s especially pleased by her final scene.

“That was an opportunity for Mary to shine and to deliver what I think was her best performance in the whole run,” he says. “And she saved it for the very end.”

“Major Crimes” Series finale 9 p.m. Tuesday on TNT