close_sha1_file(): make it easier to diagnose errors