close file handle in DownloadFileWriter
Fixes #2279 (closed). Also fixes a case where we didn't check the error when opening a file handle for a download.
Fixes #2279 (closed). Also fixes a case where we didn't check the error when opening a file handle for a download.