Fixed crash on exit.