Similar to the preferred network API introduced in #442. The Engine should expose a stat flushing API that hooks onto lifecycle events so the engine can flush stats when it is being backgrounded or killed.
This will require Envoy OSS server impl to expose the flushStats function. https://github.com/envoyproxy/envoy/blob/e7c7ca4c09acf8d389de6d5bf8f9cb005415b86a/source/server/server.h#L243