Fix possible null pointer at shutdown.