Fix for crash on exit due to cache references' not being cleared.
Merge pull request #3971 from ey6es/master

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