[Elasticsearch] Forgot to swap condition variable's value.

Also event loop now accepts error code to check its correctness after stopping.