Fixed scanner exception on exit