ios: Add FastApplicationWillTerminate to skip thread shutdown.

_chromeMain.reset() is a blocking call that regularly causes
 applicationWillTerminate to fail after a 5s delay. Experiment with skipping this shutdown call.

Bug: 1328891
Change-Id: Ia2bbdc4b07f60cca577e934cdf101c107efb705b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3664078
Reviewed-by: Ali Juma <ajuma@chromium.org>
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1007572}
NOKEYCHECK=True
GitOrigin-RevId: 85b498b0c28c769467da78a759a4d62eb3d3da3a
diff --git a/chrome/app/main_controller.mm b/chrome/app/main_controller.mm
index 5e3f7d7..d142348 100644
--- a/chrome/app/main_controller.mm
+++ b/chrome/app/main_controller.mm
@@ -141,6 +141,10 @@
 
 namespace {
 
+// Skip chromeMain.reset() on shutdown, see crbug.com/1328891 for details.
+const base::Feature kFastApplicationWillTerminate{
+    "FastApplicationWillTerminate", base::FEATURE_DISABLED_BY_DEFAULT};
+
 // Constants for deferring resetting the startup attempt count (to give the app
 // a little while to make sure it says alive).
 NSString* const kStartupAttemptReset = @"StartupAttemptReset";
@@ -769,6 +773,12 @@
     sceneState.activationLevel = SceneActivationLevelUnattached;
   }
 
+  // _chromeMain.reset() is a blocking call that regularly causes
+  // applicationWillTerminate to fail after a 5s delay. Experiment with skipping
+  // this shutdown call. See: crbug.com/1328891
+  if (base::FeatureList::IsEnabled(kFastApplicationWillTerminate))
+    return;
+
   _chromeMain.reset();
 }