Fix event loop closing