close file handles before freeing other things in got_worktree_close() The work tree's path needs to be valid while constructing error messages.