Fix event loop hang