Fix error on exit