+ struct cui *cui = cui_from_pmenu(menu);
+ char *sh_cmd;
+
+ cui_cancel_autoboot_on_exit(cui);
+
+ sh_cmd = talloc_asprintf(cui,
+ "echo \"Exiting petitboot. Type 'exit' to return.\";\
+ echo \"You may run 'pb-sos' to gather diagnostic data\";\
+ %s", pb_system_apps.sh);
+
+ if (!sh_cmd) {
+ pb_log("Failed to allocate shell arguments\n");
+ return;
+ }
+
+ const char *argv[] = {
+ pb_system_apps.sh,
+ "-c",
+ sh_cmd,
+ NULL
+ };
+
+ cui_run_cmd(cui, argv);
+
+ nc_scr_status_printf(cui->current, _("Returned from shell"));
+ talloc_free(sh_cmd);
+}
+
+/**
+ * cui_abort_on_exit - Force an exit of the main loop on menu exit.
+ * This is mainly for lockdown situations where
+ * the exit then triggers an expected reboot.
+ */
+void cui_abort_on_exit(struct pmenu *menu)
+{
+ struct cui *cui = cui_from_pmenu(menu);
+ cui->abort = 1;