After Napoleon 's defeat in Russia ( 1813 ) Frederick William turned against France and signed an alliance with Russia .
In 1813 , following Napoleon 's defeat in Russia , Frederick William turned against France and signed an alliance with Russia at Kalisz , although he had to flee Berlin , still under French occupation .