Fix for crash on exit due to cache references' not being cleared.