Fix file descriptor leaks.
Review Request #14804 — Created Feb. 10, 2026 and updated — Latest diff uploaded
We had a handful of places throughout our code where we were leaking
file descriptors (or potentially leaking, if things failed
unexpectedly). This change fixes those up.
Ran unit tests.