Use try/finally to guarantee that current directory is reset