close the downloadFile *after* checking for error