WARNING: The following article contains spoilers for Dark Phoenix, in theaters now.

With Dark Phoenix out in theaters, filmmaker Simon Kinberg has revealed which two previously released superhero films led him to extensively rework the ending to the final X-Men film to avoid direct comparisons.

Reportedly originally occurring in deep space, the final theatrical ending to Dark Phoenix takes place on a military prison train, with the extraterrestrial D'Bari attacking the convoy to seize Jean Grey and absorb the Phoenix Force from her. While promoting the film, stars James McAvoy and Michael Fassbender confirmed reshoots were done to change the ending from other similar superhero films. Kinberg has since revealed that the two films containing heavy visual similarities were Captain America: Civil War and Captain Marvel.

RELATED: Fox's X-Men Movies Drop One Final F-ing F-Bomb in Dark Phoenix

"My original ending didn’t have the entire X-Family together the way they are in the film now. More than Captain Marvel, you could see a lot of Civil War in that ending. Usually, these big, huge action movies have the climactic moment in the third act," explained Kinberg in an interview with io9. "I loved the way that Civil War had its big action action set piece where everyone’s facing off more towards the end of the second act rather than in the third, so that after that huge battle, you’re left with Winter Soldier, Captain America, and Iron Man."

Kinberg noted the originally planned ending to Dark Phoenix was considerably scaled down rather than featuring the X-Men and Brotherhood of Mutants joining forces against the D'Bari. Additionally, Kinberg revealed an intended sequence with the Phoenix Force-enhanced Jean flying in space resembled the powered up Carol Danvers defending Earth from the Kree at the end of Captain Marvel.

RELATED: Dark Phoenix Made a Mistake By Revealing Mystique's Death in the Trailers

"It’s this telescoped down view of their raw emotions, and I loved how intimate that was," continued Kinberg. "That’s what I was going for with Dark Phoenix’s ending even though it then might have looked like Captain Marvel for about two minutes."

Directed and written by Simon Kinberg, Dark Phoenix stars James McAvoy, Michael Fassbender, Jennifer Lawrence, Nicholas Hoult, Sophie Turner, Tye Sheridan, Alexandra Shipp, Kodi Smit-McPhee, Evan Peters and Jessica Chastain.