vm: fix watchdog cleanup to uv_stop() loop

Previous code was calling uv_loop_delete() directly on a running loop,
which led to race condition aborts/segfaults within libuv.  This change
calls uv_stop() before joining the thread and then calls uv_loop_delete().

Fixes #5564.