shutdown function for cache and db