clean up properly when an exit request has occured