Added more code for quitting