message: Fix race condition during server shutdown lifecycle notification
diff: @@ -627,11 +627,9 @@ void InstanceImpl::notifyCallbacksForStage(Stage stage, Event::PostCb completion
  // Wrap completion_cb so that it only gets invoked when all callbacks for this stage
  // have finished their work.
  - std::shared_ptr<Event::PostCb> cb_guard(new Event::PostCb([] {}),
  - [this, completion_cb](Event::PostCb* cb) {
  - ASSERT(std::this_thread::get_id() == main_thread_id_);
  - completion_cb();
  - delete cb;
  + std::shared_ptr<void> cb_guard(new int(0), [this, completion_cb](int* sentinel) {
  + dispatcher_->post(completion_cb);
  + delete sentinel;
  });
  // Registrations which take a completion callback are typically implemented by executing a
  @@ -643,7 +641,7 @@ void InstanceImpl::notifyCallbacksForStage(Stage stage, Event::PostCb completion
  if (it2 != stage_completable_callbacks_.end()) {
  ENVOY_LOG(info, "Notifying {} callback(s) with completion.", it2->second.size());
  for (const StageCallbackWithCompletion& callback : it2->second) {
  - callback([cb_guard] { (*cb_guard)(); });
  + callback([cb_guard] {});
  }
  }
  }
  