chdir out of the directory before cleanup