Added var PWD so that we can 'cd' to it before exiting. Only one of the three possible exits requires restoring 'cd'.