Handle quit events.