fixed null pointer exception for logging while closing