Fix File descriptor leak related to GH-1324.