Catch errors early in shutdown so later stages proceed.
Ensure limited logging during shutdown.

The logging system stops accepting messages during the JVM shutdown process.
Work around this for some important messages by writing them directly
to stderr.