Fix up logging and shutdown