Modified clear cache bug when cache is closing.