WI: Charles XII didn't die but still losses the Great Northern War

Charles XII was one of the most famous or infamous (Depending on your view) Swedish kings. Already at a young age when the Great Northern War, he already defeated the Denmark-Norway, the Polish-Lithuanian Commonwealth under the King of Saxony, and finally turned his attention to Russia under Peter the Great. He won a series of victories, most famously the Battle of Narva, and Peter the Great tried to sue for peace, which could've ended the war.

However, Charles XII didn't accept. So, he marched to Moscow, and was successfully initially, but then the Swedish Army was defeated during the Battle of Poltava. Hard.

Following the disastrous campaign, Charles XII and his army had to flee south, and made to the Ottoman Empire. There, he would spend for 5 years away from Sweden until Ottomans got tired of him and had to kick the Swedes out. Meanwhile, Denmark-Norway, the Polish-Lithuanian Commonwealth rejoined the war, and also Great Britain and Prussia as well.

So, Charles XII then made an attempted to take Norway, trying to get the Danish out of the war. However, during the Siege of Fredriksten, Charles XII died after being shot in the head by a musket ball (Most likely from the enemy-side, though some claimed it was assassination). With Charles XII's death, ended the Swedish Empire domination in the Baltic, and began the rise of the Russian Empire. Charles XII is remembered as exceptionally skilled military leader and tactician as well as an able politician, but stubbornly refused to quit a war that ended Sweden's time as a great power.... And also remember by Sabaton fans.

With that context out of the way, here is the question for today; What if Charles XII didn't die at the Siege of Fredriksten, but still loses the Great Northern War?
Now before we do, here are two outcomes, given that Charles XII was pretty stubborn to surrender: 1) Charles XII is forced to surrender by his enemies, or 2) Charles XII is overthrown by his nation.

With those two outcomes out the way, what could happen to Charles XII in a post-Great Northern War? He never married and seemed to be looking for someone of his own choice and for love rather than dynastic pressures. How would he rule in a time of peace, if he hadn't been overthrown?
 
Top