prevent event loop from being quit twice