fix event loop not terminating