bug-22445: Fixed issue where we were closing a file descriptor twice in a row