Warning: The following contains SPOILERS for Supergirl's season 5 finale.

Supergirl season 5 ended on a major cliffhanger, with the life of Brainiac-5 hanging in the balance and no clear way for the super-intelligent alien hero to survive into season 6. Thankfully, there are several potential methods of escape, all based around story elements introduced over the course of Supergirl season 5.

The second half of Supergirl season 5 was set in a radically different world than the first half, thanks to Lex Luthor rewriting reality during the Crisis on Infinite Earths event. With Luthor now running the Department of Extranormal Operations (DEO) and focusing his intellect on defeating the alien organization known as Leviathan, Querl Dox (aka Brainiac-5) found himself between a rock and a hard place, as his allies began abandoning the DEO to form their own independent superhero team to fight Leviathan and Luthor. Normally, Dox would have gladly joined them, but he had been informed by his doppelganger from another universe that they had defeated Leviathan in her world, yet had only been able to do so by working with Luthor.

Related: Why Supergirl's Heat Vision Is Blue In The Arrowverse

With Supergirl and the rest of National City's heroes unwilling to consider such an alliance, Dox went his own way, seemingly becoming Luthor's willing partner while secretly passing information on to the Super Friends and trying his best to negate Luthor's excesses. In the end, Brainiac-5 was able to enter into Leviathan's home base and used the technology perfected by his people to trap planets in bottles to capture the essences of Leviathan's leadership without killing them. Unfortunately, Luthor had anticipated Dox's betrayal and seized the bottle for himself, leaving Brainiac-5 to die a slow death from radiation poisoning in Leviathan's headquarters.

Jesse Rath, who plays Brainiac-5, has been confirmed to be returning for Supergirl season 6. However, it's not immediately obvious how Brainiac-5 could survive the trap he found himself in at the end of Supergirl's season 5 finale. Thankfully there are several options, all of which were suggested over the course of the second half of Supergirl season 5, which could be utilized without seeming like a last minute deus ex machina.

Theory 1: Brainiac-5 Enters The Coluan Hive Mind

Meaghan Rath and Jesse Rath as Brainiac-5 in Supergirl Season 5 finale

Supergirl season 5, episode 10, "The Bottle Episode," was the first episode to air after Crisis on Infinite Earths ended and was notable for introducing several alternate-universe versions of Brainiac-5, who were left stranded on Earth-Prime after their respective Earths were wiped from existence. The episode also introduced the idea of the Big Brain: a hive-mind developed by the people of Colu, Brainiac-5's home-world, which allowed their minds to continue living in a telepathic matrix accessible by other Coluans. The episode ended with the alternate versions of Brainiac-5 electing to join with the Big Brain, allowing the Brainiac-5 of Earth-Prime to continue living as the one and only Querl Dox of the post-Crisis reality.  However, the Brainiac-5 doppelgangers continued to show up throughout Supergirl season 5, summoned whenever Brainiac-5 needed to pick the brain of a equal regarding his plans and, in Supergirl's season 5 finale, so that he would not be alone when he died.

While the science behind the Big Brain was not explained, it apparently absorbed the physical bodies of the alternate Doxes or converted them into digital data upon their absorption. Presumably the process could be reverse-engineered or the consciousness of a single Coluan could be transferred into a an inert host body or robotic body (a feat accomplished by various versions of Brainiac in the comics). This could allow Brainiac-5 to be saved by temporarily transferring himself into the Big Brain. Conversely, the female doppelganger he summoned may be able to manifest herself physically and pull her other self to safety before he dies.

Related: How Crisis On Infinite Earths Changed Supergirl's History

Theory 2: Brainiac-5 Uses Toyman's Immortality Code

Jeremy Jordan as Evil Toyman AI from Supergirl Season 5

Another doppelganger figured into the aftermath of Crisis on Infinite Earths as part of the second half of Supergirl season 5: an evil version of Winn Schott, who had been corrupted by his mad father's legacy and adopted the Toyman identity in earnest. This Toyman was apparently defeated by Supergirl and her allies (including the original Winn Schott), but his loss was part of a larger scheme involving his efforts to develop an artificial intelligence based on his brainwave patterns. This Toyman AI was later able to take over the computers of the DEO, briefly turning all the drones and armored suits controlled by the organization into its own arsenal of wonderful toys. This incident served to inspire Lex Luthor, who tasked Brainiac-5 with finding a way to reverse engineer Toyman's so-called "immortality code" and use it to program mortality into the seemingly immortal and digitally-empowered aliens of Leviathan.

While Brainiac-5 ultimately went another way with his own plans to stop Leviathan, he was shown to be studying and researching the Toyman AI over the course of Supergirl season 5. It's entirely possible that Brainiac-5 decided to use the immortality code upon himself to leave a back-up of his mind somewhere in the likely event of his death battling Leviathan. Indeed, given that Coluans are semi-cybernetic in nature already, it may have been even easier for him to find a way to take advantage of the code while working around the Big Brain shared by his people.

Theory 3: Dreamer Saves Brainiac-5 At The Last Moment

Dreamer Costume in Supergirl

While Brainiac-5 regretted driving his friends away as part of his plan to go undercover and work with Lex Luthor, his deepest regret was ending his romance with Nia "Dreamer" Nul in order to protect her. The two had several awkward encounters over the course of the second half of Supergirl season 5, with it being made clear that Querl Dox still loved Nia Nul, even if he was totally unable to say so thanks to the logical part of his mind overriding his emotions. Nia, for her part, tried to move on, but kept being tormented by visions of Brainiac-5 that she took to be her own subconscious hang-ups influencing her dreams of the future. It was not until Supergirl's season 5 finale that Dreamer realized her visions were showing her Brainiac-5 sacrificing himself to stop Leviathan, and that the man she loved needed her help.

It remains to be seen if Dreamer can follow the clues in her vision to locate Brainiac-5 in time. Yet it seems like this was the most likely outcome for the writers of Supergirl to have been working towards before the shooting on season 5 was cut short by the COVID-19 pandemic. Ignoring that, the Arrowverse is the sort of setting where true love conquers all, and there's a certain dramatic irony to Brainac-5 ultimately being saved by the love he abandoned and a precognitive superpower that defies his beloved logic.

More: Supergirl vs. Superman: Which Arrowverse Hero is More Powerful