diff --git a/examples/placeholder/linux/include/TestCommand.h b/examples/placeholder/linux/include/TestCommand.h index f40f1466c9d14e..027e6f53d17a47 100644 --- a/examples/placeholder/linux/include/TestCommand.h +++ b/examples/placeholder/linux/include/TestCommand.h @@ -87,7 +87,21 @@ class TestCommand : public TestRunner, void Exit(std::string message, CHIP_ERROR err) override { LogEnd(message, err); - SetCommandExitStatus(err); + + if (CHIP_NO_ERROR == err) + { + chip::DeviceLayer::PlatformMgr().ScheduleWork(AsyncExit, reinterpret_cast(this)); + } + else + { + SetCommandExitStatus(err); + } + } + + static void AsyncExit(intptr_t context) + { + TestCommand * command = reinterpret_cast(context); + command->SetCommandExitStatus(CHIP_NO_ERROR); } static void ScheduleNextTest(intptr_t context)