code: public void onShutdown(){
          CacheRegistry.getInstance().clearDynamicServices();// clear dynamic cache services
          synchronized (allCaches) {
              for (String cacheName : allCaches.keySet()) {
                  CacheService cachingObj= allCaches.get(cacheName);
                  cachingObj.clearCache();
              }
          }
      }
docs: Method that gets invoked when the server
  shuts down