Fix exception on exit.