process: properly close file descriptor on exit
This makes sure the file descriptor is closed syncronously on exit instead of using the asyncronous version which should not be used on exit.
This is pulled out from #24965 as suggested by @addaleax.
Refs: https://github.com/nodejs/node/pull/24965/files#r240770314
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines