"The Polish war is our war; win or lose, it is our gain or loss. This German war, I don't know what it is, only that we pour our blood here for the sake of reputation, and have nought but ingratitude to expect." -Swedish Chancellor Axel Oxenstierna, letter to Johan Banér, 28 October 1634
Despite having these thoughts, the chancellor soon after made the decision to make a lasting peace with Poland and keep fighting in Germany - for another fourteen years, as it turned out.
In the end, it turned out all right for Sweden, but that outcome was far from inevitable from the perspective of 1634 and 5, when the Swedish presence in Germany was at its weakest point yet since the death of Gustavus Adolphus. This is a timeline where Sweden chooses its battles more cautiously and where the Thirty Years' War of OTL slowly glides to a stop in just under twenty.
Background: The collapse of the Swedish conquests
Gustavus Adolphus had brought large parts of Germany under Swedish control, either directly through his network of garrisons and field armies, or indirectly through his system of allies. But his personality and reputation were the main ties holding this conquest together, and after his death (1632) it began to unravel. Without the late king, Chancellor Axel Oxenstierna could not maintain it. The Battle of Nördlingen in 1634 destroyed the main Swedish army in southern Germany, and by the autumn of that year, most of the south was either under enemy Habsburg control or in complete disarray. France had entered the war against the Habsburgs and was becoming the dominant partner, gradually taking control of the troops and assets of Sweden's allies.
Emperor Ferdinand III made things even worse for Sweden in 1635 with the Peace of Prague, a generous set of terms for any German princes who stopped fighting against him. The Peace addressed many of the casus belli that were driving the war. Soon, such key Swedish partners as Saxony, Brandenburg, and the Brunswick duchies were leaving the alliance. Even the Landgrave of Hesse-Kassel, a stalwart anti-Habsburg, was negotiating terms with the emperor.
Sweden's military strength in Germany was down to just 33,000 soldiers, most of whom were German mercenaries. These were unpaid and mutinous - a group of officers briefly captured Oxenstierna himself in August 1635 and forced a promise to include money for them in his (believed to be imminent) peace terms.
Meanwhile, a new war was about to break out. Before invading Germany, Gustavus had invaded and occupied a large part of Polish (western) Prussia. This war had ended with a truce, which was about to expire in September of 1635. It was readily apparent to everyone that Sweden could not resume one war in Poland while continuing another in Germany. The question was which war Oxenstierna would choose to fight.
POD: The road to peace
During the months leading up to the expiration of the Polish truce, France scrambled to keep Sweden from leaving the German war. Cardinal Richelieu sent envoys to mediate between Sweden and Poland in the hope of renewing the truce. He offered Sweden generous subsidies and reinforcements to help maintain its army in Germany. For Sweden, it was a trade-off: French subsidies would do much to boost the national revenue, but Sweden could potentially make even more money by remaining in Prussia and collecting tolls and customs from its ports.
The PoD is the breakdown of the Polish-Swedish talks in the village of Stuhmsdorf (Sztumska). Oxenstierna had made the choice to remain in Prussia and fight for Sweden's permanent possession of it.
At the same time, Swedish envoys had approached Saxony with an offer to accept the Peace of Prague and stop fighting in Germany as long as certain conditions were met. The Saxon Kurfürst, Johann Georg, for decades Germany's most enthusiastic (and ineffective) peacemaker, eagerly passed along the news to Emperor Ferdinand.
The Peace of Prague and the Nordhausen settlement
Sweden had just won a minor victory over Saxon, Brunswicker, and Brandenburger forces (all former allies) at Dönitz, so the Swedes were able to negotiate from a position of relative strength. Johann Georg didn't mind, and Sweden agreed to a temporary truce with Saxony just as the truce with Poland was breaking down.
At the Thuringian city of Nordhausen, Saxony negotiated peace between Sweden and the Habsburgs. Representatives from the Emperor accepted preliminary terms from Sweden in December 1635. Fighting was to cease, and upon ratification of the treaty, Sweden would disband its troops to set levels and withdraw the rest to its own territory. It would abide by the Prague Peace terms, meaning that its German territories would always have to pay taxes to help fund an imperial army. This territory would be somewhat enlarged. Ferdinand, more appreciative than his predecessors of the power of a good compromise, did give Sweden a lot of what it wanted, since the alternative was endless war. Sweden got all of Pomerania west of the Oder, plus the port of Wismar in Mecklenburg. It would receive a subsidy from the imperial treasury to help pay off its troops, and could collect tolls at Kolberg, eastern Pomerania until these were paid off.
The Nordhausen settlement would take more than a year to be formally ratified, but it effectively ended Sweden's German adventure. It brought peace to eastern and northern Germany and allowed Sweden to pursue another war in Poland.
The greatest long-term impacts of the Peace were that (1) The Holy Roman Empire would henceforth look to the Prague Peace as its major constitutional document, and (2) the war was settled with a series of small treaties. The precedent of a great international peace conference set in Westphalia in OTL did not happen.
The dispersal of Swedish forces
Some of Sweden's armies had already begun defecting before the peace was signed, some going over to French service, others to the Emperor. The largest concentration of troops was in Pomerania, garrisoning the towns or wintering near the border. Another army of nine regiments was cut off in northwestern Germany, the remnant of a once-large occupying force. A third army occupied the city of Erfurt, and a small garrison still held on to the ruined city of Magdeburg. Upon the Nordhausen settlement, these troops were dispersed in different directions.
The regiments in northwestern Germany decided that their best option was joining the French to continue fighting. A few French officers joined them in early spring and moved them further west to be closer to French positions.
The Erfurt army was largely broken up or transferred to Saxon service, in the spirit of fulfilling Sweden's obligation to provide for the imperial army.
Magdeburg was also transferred to Brandenburg and its garrison paid off and disbanded.
The main army was broken up. 10,000 troops, including most of the soldiers from Sweden, were transferred to the Prussian front. Johan Banér, the commander of the army in Germany, was with them and assumed command of the army in Prussia. He led Sweden in the next phase of its Polish war. Around 10,000 more soldiers were retained to defend Pomerania. This was more than the treaty allowed for, but it was not contested. The rest were disbanded gradually as Sweden found the money to pay their arrears.
Political impact, and the French war
In Germany, the last holdouts against the Prague Peace lost their combativeness when Sweden stopped fighting. Hesse-Kassel accepted the terms a few months after Nordhausen, and other small pockets of resistance followed it. France was left to fight the Habsburgs alone. Its few remaining allies were largely territories that France already occupied, or who had tied their fortunes to the French invasion and could not be welcomed back into Imperial politics under the Prague terms.
French troops in southwestern Germany immediately went on the offensive, hoping to weaken Habsburg and Bavarian positions before a united imperial army could be formed. An invasion set out along the Danube before the snow had completely melted in 1636. It won some impressive small victories but was eventually forced back.
French generals calculated that it would be best to consolidate its gains in the hope of leaving the imperial war with some substantial conquests. The fighting in 1637-8 consisted of small operations to secure the Franche-Comté and Lorraine, and other areas just across the French border. Emperor Ferdinand tried to mobilize his forces now that France was the only major belligerent left. However, his efforts were frustrated. Sweden was demobilizing its German army slower than it had promised, forcing the Emperor to keep one eye looking northward in case the Swedes should violate the peace. Germany itself was suffering from intense war weariness. Parts of the country were devastated and depopulated. Many imperial princes, obligated under the Prague terms to contribute troops to defend Germany against foreign attackers, resorted to stalling and protesting that they were unable to meet their commitments. Many at any rate thought the western border was indefensible and were not prepared to risk more lives and money to reconquer it for Ferdinand. Finally, Habsburg finances were in a disastrous state. Ferdinand was unable to fully drive the French out of Germany.
In the meantime, though, France's war with Spain continued. With fighting continuing in Flanders and the Pyrennees, France found itself battling the Habsburgs on three fronts. The German front held steady, as described above. In 1637 Richelieu organized a great attack against Antwerp with Dutch support.
The resumption of the Polish War
Sweden already occupied one key point in Polish Prussia: a fortress at the mouth of the Vistula just below the city of Gdansk (Danzig), where it had the lucrative right to collect tolls from merchant ships under the terms of a truce in 1629. Now as soon as the Prague Peace was signed, the Swedish cavalry and artillery in Prussia joined some ships to move against the well-fortified city itself, which Gustavus Adolphus had been unable to conquer.
In the late summer of 1636, 20,000 Swedes crossed into Polish Prussia to join the troops recently evacuated from Germany. Rather than put everything into a full-blown siege, General Banér established a looser blockade and "quarantine" and advanced the bulk of his men south through the Polish countryside. His troops devastated western Poland. Banér made it as far as Warsaw before turning back for the winter, moving to positions around Torún (Thorn).