Add null pointer check.  NPE can occur during JVM exit.