Added a finally block for returning the current working directory.