Yes, Tony Stark aka Iron Man died in Avengers: Endgame, marking one of the most heartbreaking moments of the entire film. This shouldn’t be a spoiler anymore given the massive audience the film had in the more than three months since it hit theaters. Now that Endgame is available in digital format, we’ve learned even more secrets about the film from commentary features that accompany the Blu-ray version, as well as other interviews with Marvel execs. And now we know exactly how and when Iron Man’s tragic fate was decided.

Going into Infinity War, and especially Endgame, we suspected some of our favorite heroes would die, and that those deaths would be permanent. Tony Stark and Steve Rogers were among the top candidates, considering their long history together and their importance to the team. The Avengers leaders had spectacular arcs during this massive Infinity Saga, both earning their exit from the MCU. Now that Endgame is in the past and we’re looking at the next phase of MCU adventures, we know both heroes were retired. One died, and the other one got to retire and live a relatively happy life.

Talking to Empire Magazine about Endgame, Marvel president Kevin Feige revealed that Iron Man’s death was decided back in December 2015, right after Captain America: Civil War. Planning for the last two Avengers movie started some five years ago during a retreat where several key Marvel execs met to decide the future of the franchise:

We were on our third retreat, perhaps, five years or more ago, when we started talking about what would become Infinity War and Endgame. And in particular, how do we pay off this purple guy that Joss [Whedon] set up at the end of Avengers and start to intertwine him with these awesome Infinity Stones that we have that provide wonderful macguffins in all these individual films. When you put them together, we thought it could be more. And it was on that retreat that we thought of doing two movies at the same time, which has its pros and cons.

Image Source: Marvel Studios

And it turns out that Marvel drew its inspiration for Tony’s exit from one of its other properties, one that it didn’t control at the time. That’s X-Men, and in particular, Logan:

We saw Logan like the audience did, in a theater having nothing to do with the making of that film and went, ‘oh my god, what an amazing ending for Hugh as this character. And there are only a handful of examples where an actor so associated with a character can go out perfectly. And Logan is the only one that jumps to mind right now, there are not that many of them. And that’s what we desperately wanted to give Robert, and that was what our focus was on.

Marvel really wanted the end of the movie to make an impact, and there’s no better way to do that than with tragedy:

There was some sense that deaths don’t matter in our movies – Nick Fury gets shot and died in Winter Soldier and comes back in the third act, which was awesome, but is not a death. And people were clamouring for, not death necessarily, but stakes and real emotion. And I remember thinking, ‘be careful what you wish for,’ as we started getting closer to this. But we never questioned it. All of the angst and all of the effort went into sticking the landing, to making it worthwhile.

As for Robert Downey Jr., the actor knew as far back as December 2015 that Tony would die:

I remember pitching that to Robert Downey Jr. probably in December of 2015, I think. I pitched him the idea of the two-part finale for Avengers and Spider-Man: Homecoming, which was a part of that leading into it. It took a little while, but eventually, it came together. I think at first it doesn’t seem real that this journey will come to an end. But as it got closer to filming, it really was emotional for all of us, and particularly for him.