Lucy Liu as Joan
“Elementary” executive producer Rob Doherty and series star Lucy Liu said that the shocking death in Season 5, episode 22 will immensely affect Joan and Sherlock (Jonny Lee Miller) in the last two episodes of the season. CBS

“Elementary” shocked its viewers at the end of last night’s Season 5, episode 22 when Joan (Lucy Liu) found Shinwell (Nelsan Ellis) dead in his apartment. In a couple of interviews following the airing of the installment, executive producer Rob Doherty explained why Shinwell had to go ahead of the Season 5 finale of the CBS series.

“We wanted an opportunity to watch his death wash over Sherlock (Jonny Lee Miller) and Joan,” Doherty told Entertainment Weekly. “It affects them in very different ways. Each had a very different relationship with Shinwell as of his passing. So in the last two episodes of the season, it’s going to be a point of friction. Over the last 10 or so episodes, Shinwell’s been exposed, for better or worse, as someone with problems we can’t really solve or get past. It puts Sherlock and Joan in an interesting place as we get into the finale.”

During a separate chat with TVLine, Doherty pointed out that it was always their plan to kill off Shinwell before the season finale. “From inception, we viewed him as a tragic figure, someone that would come into Sherlock and Joan’s world, disrupt it and leave in tragic fashion,” the exec producer explained. “This was always part of the plan. We knew that we were going to pull this trigger, so to speak, at some point in the season, but it certainly felt most appropriate as we were approaching the finale. It platforms everything in a more dramatic fashion as we get into the last two episodes.”

READ: Which “Narcos” star will appear in Season 5, episode 23 of “Elementary”?

Although he knew from the very beginning that Shinwell wouldn’t survive the season, Doherty admitted that killing off the character had been difficult. “It’s never easy to kill off a character you care about, especially when you have an actor who did as fantastic a job as Nelsan Ellis,” Doherty shared. “But as I said, we always had a sense of the story and the best way to tell it. Ultimately, even though we cared a lot about the character and the actor, we still felt it was too important a part of the story we were telling to change.”

While most fans didn’t see Shinwell’s death coming, Liu revealed to CBS that she wasn’t that surprised when she found out that Shinwell was going to die in last night’s episode. “When I heard Shinwell would be murdered, I wasn’t all that surprised to be honest,” the actress said. “I think the writers did a great job of making the viewer root for him, despite his past transgressions and questionable morality. I think in the end we want to know that he is, at his core, a good person.”

Liu added that she had a great time working with Ellis. “He's incredibly talented and a wonderfully complex addition to the show,” the “Kill Bill” actress said of her co-star. “I’m sad to see him go, but I think his arc was fulfilled in a very interesting way — his demise will leave an important imprint on the leads.”

“Elementary’s” next episode (Season 5, episode 23) airs on Sunday, May 14 at 10 p.m. EDT on CBS.