Fixed error on exit