shutdown fixes, error event handling