handles exiting better