added gracefule exit on window close