Fix #179 (Crash on exit)