Fix crash on exit.