Shutdown exception was due to logging threads

The log_callback and async_log_callback functions
were being called after Python started finalizing,
and so some modules had already been cleaned up by
the time we `logging.getLogger(…)`.

Specifically, I believe it was specifically the
threading._get_ident function that was missing.

This detects that Python has started finalizing
and does not schedule the callback, or attempt to
push messages into the logging tree, and warning
is printed to std err.

Fixes #23.