Added handler to exit program when gui window is closed