cannot close main windows if script is running