Why did the Qing dynasty come to an end