Wait for libev thread to terminate on exit