fs: refactor autoClose
Simplify autoClose
logic into a helper. Also pass error through destroy
instead of emitting when possible.
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