Fixed small error involving closing window and terminating the program