I was watching If/Then/Else again in a rerun and I noticed that as soon as Harold and Root died in the simulation the Machine reset to the beginning, but when John died it kept the simulation running until the others died too. Now looking back on that after seeing the finale, I wonder if that was an indication of the deal John struck with the Machine.
As I recall, the Machine's goal was to calculate a scenario in which the team would succeed in defeating Samaritan's attack on the stock exchange. And only Finch and Root could pull that off; Reese and Fusco were just there as muscle. In those simulations, Finch and Root died before they achieved their goal, so that was a failure. In the final simulation, the one the Machine chose to go with, the hack would succeed but the team's probability of survival was effectively nil -- until Shaw showed up as an unanticipated variable and altered the odds. So the Machine was willing to accept sacrificing everyone in order to achieve the goal.
Of course, there's also the fact that Harold was the Admin and Root the Analog Interface -- both essential to the Machine -- while Reese was simply an asset, one that was always understood to be expendable for the sake of the cause, like Dillinger before him.