Fix: crash on exit