fix crash on exit.