fix error on exit