Catch quit event too