test: make sure all handles in the loop are closed

After https://github.com/joyent/libuv/commit/2611ef43b15dc083ac2ffd5f16901a4ff076be03 hell broke loose because we don't clean up after ourselves in the test suite. I could reproduce the failures in https://github.com/joyent/libuv/issues/1161 when using autoconf but not when using gyp (need to investigate that). Either way, this patch makes sure all handles in the loop are closed before destroying it.