don't leave files open after patching