Make shutdown more robust
Removed some debug logging