Fix logging error in which item_name was freed

The AVClass was being freed after the log was
issued, but before Python actually processed it
since it does so async.
Crazy "fix" for exception at shutdown
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.