ported handleExit(event)