Issue #115: ensure all fds are closed, so threads don't terminate improperly