Ensure download stream is finished closing before dealing with temp file