Additional precautions to be sure that we never crash on null pointer dereferencing when clearing resources.