Fixed a bug in switching to another window.