Fixed a bug when closing Settings window.