Ethan Hunt (Tom Cruise) returns to stop the menacing AI villain in Mission: Impossible – The Final Reckoning. From a perilous underwater rush to the Sevastopol submarine to mid-air altercations with Gabriel, the agents challenge time and space to save the world from devastation by The Entity and Gabriel.
Disclaimer: The article contains spoilers for Mission: Impossible – The Final Reckoning. Reader's discretion is advised.
Towards the end, the team stays back at the Doomsday Vault, solving impending challenges there. Ethan goes behind Gabriel to bring the Poison Pill. Ethan manages to defeat him, connecting the Poison Pill and the Podkova.
Grace captures the AI in a 5D flash drive and stops the nuclear destruction from happening. Ethan and the team reunite in London. Grace gives the drive containing The Entity to Ethan. Ethan does not destroy The Entity in the end, taking it under his possession before vanishing amidst the crowd in London.
Mission: Impossible – The Final Reckoning ending explained: How does Ethan and his team plan to capture The Entity?

In Mission: Impossible – The Final Reckoning, the Entity ushers in its terror with a massive takeover of the global cyberspace. It controls citizens, creating a war-like situation between the governments and people. Growing its power across organizations, the AI begins controlling the nuclear weapon systems of various countries.
Gabriel, who previously worked for the Entity, dreams of taking over it now and goes behind Ethan to bring him the AI's source code so he can yield supreme power over it.
Further in Mission: Impossible – The Final Reckoning, Ethan successfully reaches the submerged Sevastopol submarine after his team helps with locating it through exact coordinates. He gets hold of the Podkova, a device containing the source code of The Entity. The high-risk task makes him face the underwater pressures and their severe effects on his body. But he manages to bring it back safely and is rescued by Grace and Dunloe's wife, Tapeesa.
The source code could bring an end to the devastating AI that had taken over global cyberspace. As Ethan, Benji, Grace, Paris, Degas, Dunloe, and Tapeesa move ahead with the mission, Ethan and Benji explain the next course of action they must take.

It is revealed in Mission: Impossible – The Final Reckoning that the team must go to Kongo Yowa, South Africa, where the Doomsday Vault is located. Tricking The Entity to access inside the vault, they plan to capture it in a 5D optical data drive that their former teammate, Luther Stickwell, built. This has to be done within 100 milliseconds, failure in which could empower The Entity to activate nuclear weapons of the countries that possessed them.
Another requirement for the plan is to get back the Poison Pill from Gabriel, which Luther has created. It contains code that, when connected with Podkova, would create a digital toxin to curb The Entity. The team plans that they will make Gabriel connect the Podkova with the Poison Pill. As soon as it is done, Grace will get the Entity in the flash drive, stopping the catastrophe.
While the plan sees a lot of changes towards the end, Ethan and his team get hold of The Entity and defeat Gabriel. Later, when Grace gives the flash drive containing the AI to Ethan, he does not destroy it, but keeps it in his possession as he leaves. It may mean that he plans to have it with him to avoid anyone else gaining access to it.
Also read: "I only want it if it self-destructs" - Fans react as Mission: Impossible – The Final Reckoning reveals elaborate popcorn bucket
What new challenges do Ethan and his team face in their plans at the end of Mission: Impossible – The Final Reckoning?

As the team reaches the Doomsday Vault, they find out that Gabriel had planted another bomb at the site. While Ethan Hunt goes to hand over the Podkova to Gabriel as per their plan, Kittridge and Jim Phelps Jr. from the IMF reach the location and stop the team.
Kittridge pressurizes Ethan to tell him about the Podkova and his plan, but is soon stopped as Gabriel's men start attacking them all. Amid the intense gun fight, Gabriel escapes from the site before the bomb blasts.
In a change of plan, it is decided that Ethan will chase down Gabriel and connect Podkova with the Poison Pill. Benji, Grace, and Paris head to the vault to capture The Entity in the flash drive. Degas, Dunloe, and Tapeesa work on detonating the bomb to avoid major destruction, even if it means they would have to sacrifice their lives for it.

As Ethan leaves, Benji reveals that he was shot in the waist during the fight. In a wounded state, Benji goes on to instruct Grace on the installation of the drive in the vault and guides Paris to perform a medical procedure on him to remove the bullet and save him.
Dunloe, Degas, and Tapeesa find a way to save themselves and detonate the bomb, which requires them to run inside the vault in 10 seconds. Meanwhile, after a series of stunts on helicopters, Ethan reaches Gabriel to take the Poison Pill from him. He manages to push Gabriel off the aircraft and connect the Podkova and Poison Pill mid-air.
As soon as he does so, Grace captures The Entity in the drive, and the three working on the bomb come back safely. Benji is also saved by Paris. Ethan lands safely using a parachute.
Also read: 7 movies to watch if you liked Mission: Impossible – The Final Reckoning
Ethan keeps The Entity with him at the end of Mission: Impossible – The Final Reckoning

As the team completes the mission successfully, the world gets restored to its previous version, free from AI control. American President Sloane is also relieved at the end because no severe steps or casualties were recorded, as Ethan saved the day again.
Jim Phelps Jr., son of Ethan's former trainer and the first film's antagonist, Jim Phelps, also warms up to Ethan finally after his success. When the mission is completed, it is shown in the film that the team later reunites in London.
Ethan feels elated to see all his teammates back safe after the prolonged and high-risk mission they embarked on. Grace approaches him and hands him the drive that contains The Entity. Previously, Ethan had mentioned in the movie that he intended to destroy the AI forever, having no risk of it coming into the hands of any other person or authority.
However, he takes the drive later and keeps it with him, not destroying it in reality. He immediately vanishes in the crowd as Mission: Impossible – The Final Reckoning ends at this point. With no post-credit scenes or indication, it may suggest that Ethan decided against destroying The Entity. This could be due to the possible risks and destruction in cyberspace it may cause, or just to keep it away from bad hands.
Stay tuned for more updates on Mission: Impossible – The Final Reckoning.