fixed crash on exit