Make sure chip-tool interactive cleanup happens on the Matter thread. (#21661)

The interactive cleanup happens while the event loop is still running
(during the execution of the "interactive" command), so queuing the
cleanup on the event loop is reasonable.  And this ensures cleanups
don't run into MAtter locking assertions.
diff --git a/examples/chip-tool/commands/common/CHIPCommand.cpp b/examples/chip-tool/commands/common/CHIPCommand.cpp
index 8649efc..e511ebb 100644
--- a/examples/chip-tool/commands/common/CHIPCommand.cpp
+++ b/examples/chip-tool/commands/common/CHIPCommand.cpp
@@ -453,7 +453,7 @@
 #endif // CONFIG_USE_SEPARATE_EVENTLOOP
 }
 
-void CHIPCommand::ExecuteDeferredCleanups()
+void CHIPCommand::ExecuteDeferredCleanups(intptr_t ignored)
 {
     for (auto * cmd : sDeferredCleanups)
     {
diff --git a/examples/chip-tool/commands/common/CHIPCommand.h b/examples/chip-tool/commands/common/CHIPCommand.h
index 7688a34..02a30eb 100644
--- a/examples/chip-tool/commands/common/CHIPCommand.h
+++ b/examples/chip-tool/commands/common/CHIPCommand.h
@@ -115,7 +115,7 @@
     virtual bool DeferInteractiveCleanup() { return false; }
 
     // Execute any deferred cleanups.  Used when exiting interactive mode.
-    void ExecuteDeferredCleanups();
+    static void ExecuteDeferredCleanups(intptr_t ignored);
 
 #ifdef CONFIG_USE_LOCAL_STORAGE
     PersistentStorage mDefaultStorage;
diff --git a/examples/chip-tool/commands/interactive/InteractiveCommands.cpp b/examples/chip-tool/commands/interactive/InteractiveCommands.cpp
index 33b030a..38e706b 100644
--- a/examples/chip-tool/commands/interactive/InteractiveCommands.cpp
+++ b/examples/chip-tool/commands/interactive/InteractiveCommands.cpp
@@ -89,7 +89,7 @@
 {
     if (strcmp(command, kInteractiveModeStopCommand) == 0)
     {
-        ExecuteDeferredCleanups();
+        chip::DeviceLayer::PlatformMgr().ScheduleWork(ExecuteDeferredCleanups, 0);
         return false;
     }