Here's why John Reese (Jim Caviezel) had to die in Person of Interest's series finale. Reese, a former Special Forces soldier and CIA agent, was one of the show’s two central characters for all five seasons of the CBS series. In the beginning, Person of Interest focused on Reese and Finch's (Michael Emerson) efforts to prevent murders before they happened by tracking down social security numbers provided by the Machine.

Person of Interest’s fifth and final season then focused on the conclusion of the team’s battle with Samaritan. It all came to an end in the Person of Interest series finale, with both Reese and Finch knowing that both of them may not survive. They discover that in order to defeat Samaritan, one of them has to reach the roof of a certain building and upload the Machine to an antenna. Finch locks Reese in a vault and heads to the roof to finish the mission himself. What he doesn’t know is that Reese made a deal with the Machine to make sure Finch survives. The Machine intentionally sent Finch to the wrong building so that Reese could make the ultimate sacrifice instead.

Related: Person of Interest's Original Elias Plan (& Why It Didn't Happen)

Reese makes a dramatic last stand against the agents of Samaritan, and is violently gunned down in his last battle; it was a tragic end for one of the show’s two main protagonists. According to the producers, this was always going to be the way Reese’s story ended. Person of Interest creator Jonathan Nolan explained that the series made it clear as early as the pilot episode that both of them wouldn’t walk away alive [via Deadline]. Finch even told Reese that he expected them both to be killed. It was just a question of which one would be killed off at the end of the series.

The decision for that character to be Reese was also determined by the events of the pilot episode. In the beginning of the series, Reese was a homeless man on the street with nothing to live for. Finch gave Reese purpose by giving him a job. By helping Finch save people, Reese was able to feel like he was making a difference in a good way for the first time in a long while. Reese believed that Finch had saved him, which is something that Reese has brought up on more than one occasion. Reese always felt indebted to Finch for that reason. Nolan says that Reese’s death was him “him giving some of that back to Finch in the hopes that one of them could make it out alive.”

It made sense for Reese to die in the show’s final episode. One of the most important aspects of their relationship in Person of Interest was the gratitude that Reese felt toward Finch. The Machine and the numbers gave Reese something good to do with his life, so it felt perfectly fitting for Reese to die so that Finch finally got to share a future with the woman he loved, Grace (Carrie Preston).

More: Person of Interest Season 6: Why The Show Was Cancelled