Changed exit(1) to stage.close() for users to be able to save data before closing