Shutdown refactor to add Tasks which are guaranteed to run before the Cache is closed