Clear the libuv event loop before exiting
Previously, the event loop was processed only once when the netmgr was shutting down. After the change we clear up the event loop by running uv_run() with UV_RUN_NOWAIT flag repeatedly until there's nothing to do.
Edited by Ondřej Surý