Fix #67: Crash on shutdown