src: manage handles more explicitly in cares_wrap, node_stat_watcher
When garbage collecting ChannelWrap & StatWatcher directly call uv_close which can wake up the event loop when it's already going for a shutdown. Instead be more explicit about managing these handles throughout the lifetime of these two classes.
Refs: https://github.com/nodejs/node/pull/18307 Fixes: https://github.com/nodejs/node/issues/18190
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines