Fix resource leak, variable fd going out of scope.
Reported by: Coverity CID: 1204383 Sponsored by: iXsystems Inc.