[WARNING: The following story contains spoilers about Wednesday's episode of Criminal Minds. Read at your own risk.]

Criminal Minds flashed back to the beginning of the BAU, but it was the end for Gideon.

Seven and a half years after Gideon (Mandy Patinkin) exited that diner and drove off into the sunset, he was killed off on Wednesday's episode. In the opening minutes, the BAU — including a despondent Reid (Matthew Gray Gubler) and Gideon's heretofore unseen son Stephen (James Lentzsch) — gather at Gideon's cabin, where someone had shot their former leader dead. But before Gideon took his last breath, he fired a shot at one of his framed paintings of birds, which Rossi (Joe Mantegna) realizes is a clue.

Criminal Minds: Erica Messer and Kirsten Vangsness on writing the flashback episode

Flashing back to 1978, we learn that young Gideon (Ben Savage) and young Rossi (Robert Dunne) had to let many cases go unsolved because of a lack of resources and manpower in the nascent BAU (or Behavioral Science Unit as it was known then). One in particular stuck with Gideon and was the origin of many of his tics and obsession with birds. Three times over a couple of months, an unsub left the body of a twentysomething woman in the Roanoke County woods, each with a dead bird in her hands. But there was never a fourth woman... until now.

The body of a fiftysomething woman, Tara Barnett, whose photo Gideon had carried in his wallet since 1978, was found in the same woods the week before — no bird in hand, however — which provoked Gideon to launch his own, ultimately fatal, investigation. The team figures out the unsub is Donnie Mallick (Arye Gross), who had kept Tara captive — and snapped her limbs — in his bird lair until her death from cancer, because she was an ideal substitute for his wheelchair-bound ornithologist aunt who raised him. Fittingly, Rossi, whose middle name we learn in the flashbacks is Stephen, avenges Gideon's death.

So why was it time for Gideon to die? Why didn't they kill him when Patinkin abruptly left back in Season 3? How will Reid deal with the loss of his mentor and chess buddy? Executive producer Erica Messer, who co-wrote the episode with star Kirsten Vangsness, answers our burning questions.

Had you wanted to kill off Gideon for a while or did this come about when you were breaking the episode?
Erica Messer:
I had the idea of the '70s of it all more than anything. And then it was like, "What is an important enough case that would warrant us going back and seeing where it all started?" Having it be this character, who we haven't seen in forever but we're going to see where it started with him, it just felt right to see where it all ends for him. You're seeing his whole life as an FBI agent and the personal side of having a child he wanted to have but maybe wasn't as good of a dad as he wanted to be. It felt like a really nice way of honoring Gideon. We don't kill off our heroes very often. We did Strauss obviously. But it felt like after 10 years, these are things that do happen to agents who have worked together for a long time. Their friends die, even in the line of duty. All of our fans who've been watching for 10 years, all of us who've been working here 10 years and the actors who've been living these characters for 10 years — it was like, "Let's give them some real drama." When it hits home, it doesn't get more real than that.

It was befitting the character. Gideon has always been haunted by cases and took things home with him.
Messer:
Yes, definitely. Gideon had retired to get away from it, but the fact that he was pursuing this case and it was the thing that ultimately killed him, it felt like a very real thing for that character. He was always so passionate and committed to being a good guy.

SAG Awards: Check out the fashion hits and misses

Did you ever consider killing him off earlier, like when Mandy left?
Messer:
When Mandy left eight years ago, there were a gazillion ways to go. We chose the most honest version, which was to write what was really happening. Sure, for a heartbeat it might've been on the table, but creatively, we didn't ever want to seem like it was punishment, like we were killing a character to punish him. This certainly is not that. This is playing to the heroes and the wins and the losses that they have over their careers. Like you said, Gideon was haunted and took things home with him. It seemed fitting that he was killed in his home because of a case he never let go of. It was the origin of keeping things in his wallet, the origin of his bird obsession. All of these things were a nice tribute to a character who we really only knew for two years, but he has a deep, long legacy in the mythology of the show. And why not explore that?

It was nice to see Rossi and Gideon interact in some incarnation. Rossi always talks about working with Gideon, but obviously we had never seen them share the screen.
Messer:
Yeah, it was so fun to see young Gideon and young Rossi, and how the BAU operated really with just the two of them back then. And you see how close they were and that Gideon named his son after him. It just felt like it was time to tell that kind of story.

Some fans don't like Gideon because of how Mandy left and his subsequent comments about the show. How conscious were you of that when you were writing or were you focused on paying tribute to Gideon?
Messer:
We are always very aware of how our fans think and feel about these characters, but honestly, it was all about how our team would react to this loss. When you think about it in those terms, I think the audience is on board. They want to watch this group of heroes and if they're suffering the loss of someone they once worked with, the minute you see Reid with those quivering lips, it's like, "Oh, my gosh!" I think no matter how you feel about Gideon as a viewer, you're completely emotionally invested because the team was completely emotionally invested.

When I saw him drive up to his cabin, I knew Gideon was dead. It's only bad news when Reid drives up to his cabin.
Messer:
[Laughs] I'm so glad you picked up on that because those are the things we did on purpose. ... We didn't want to exactly copy the previous moment, but it's dark, quiet, Reid is pulling up in his old car. The last time he did that was outside of Gideon's cabin. That's exactly what we intended. ... I mean, people come and go from work. Those who've been here for 10 years, I can't even tell you how many people have come and gone in 10 years here. Why not write to that? That's what happens in work, in life, in everything else. We always approach it that way and we always just try to honor the mythology.

Did CBS or ABC Studios have any reservations about killing off Gideon?
Messer:
I pitched it and they were on board with the '70s flashback. I said, "What I really want to drive us back into the past is the death of Gideon." And they said, "We agree." It was good. Everyone was fine with it. I think they realize enough time has passed that we're not gonna have [Patinkin] again. And the beautiful thing about television is that if for any reason we did have him again, he can come back in a flashback. He's not coming back in the present, but ... [Laughs]

SAG Awards: Check out all the red carpet arrivals

Or you can just get Ben again.
Messer:
Exactly! He was so good. I think it's certainly something that excites all of us. You won't see him again in Season 10, but it's something we're considering for the future.

How will everyone grieve going forward? Reid understandably took it the hardest.
Messer:
Yeah, Reid's now seen a lot of loss the past few years. He's sort of matured in that way that we all do. Death can happen to us at any time. There will be a sadness there that plays into the next episode a little bit, but it's his version of dealing with it. It's really bittersweet. Rick Dunkle wrote that one. It sort of continues the tribute to the character, especially the history between Rossi and Gideon, and Reid and Gideon, so therefore Rossi and Reid. It's a really lovely continuation and then it becomes one of those things that the characters add to their layers. They've seen deaths of colleagues. It makes you look at the job differently. I love how Hotch and Rossi had such a nice moment at the end. They didn't say anything about murder for once. [Laughs]

What was it like writing with Kirsten?
Messer:
Oh, my God! So much fun! She's friends with Arye Gross ... and the minute [he] came on board as the unsub, we were like, "Oh my, God! Now we gotta look at these scenes with him in mind because he's amazing." We just really had good time. ... She's always sunshine and rainbows, but she'd suggest all this gross stuff, and I was like, "Oh my God! That's really scary! Let's do it!" ... We might [write one] next season. She and I need to talk about it. But this was a blast.

What did you think of Gideon's death?

Criminal Minds airs Wednesdays at 9/8c on CBS.

(Full disclosure: TVGuide.com is owned by CBS.)