Close fd after using it and before deleting it (refs #4075)
Merge pull request #936 from thingthing/3.2-I4075

Close fd after using it and before deleting it (closes #4075)