The personal union with Sweden lasted until the death of Charles XII of Sweden in 1718. When Charles XII died without children, the Swedish crown was inherited by his sister Ulrika Eleonora, while Zweibrücken went to his cousin Gustav, Duke of Zweibrücken. Because of this, exiled Polish King Stanisław Leszczyński who had been named Count Palatine of Zweibrücken as a Prince exercising the head of state's authority on behalf of Charles XII in 1714 was forced to leave a year after his death in 1719.