fixed crash on exit.