Fix a bug where SingleThreadEventExecutor sets its internal state flag too early during termination