Sync temporary files before closing and renaming.