API hooks for app shutdown (so we may close database safely)