CHEF-4625: Explicitly close temp files to prevent sharing violations
Handle nil tempfile, ftp, http cases