Skip to content

system.exit

since 1.1.0

Exit the current script.

system.exit()

Parameters

None.

Returns

Nothing.

Examples

-- close a system tool from a button
form.addButton(line, nil, { text = "Done", press = function() system.exit() end })

In a widget's configure form, system.exit() leaves the configuration page, as FrSky's gauge example does with an Exit configuration button.

Used in

Real-world usage

Called 8 times across 5 open-source Ethos Lua projects. A few short excerpts:
if value == KEY_RTN_LONG then
    log("KEY_RTN_LONG", "info")
    invalidatePages()
    system.exit()

src/dashx/app/app.lua:404

local function goBack()
  if menuGuard and menuGuard.close then menuGuard.close() end
  local hadFrame, parentScreen = nav.pop()
  if not hadFrame then
    system.exit()
    return
  end
  openScreen(nav, menus, rootEntries, parentScreen, setEventHandler, setWakeupHandler, setPaintHandler, setCleanupHandler, taskGuard)
end

src/rfsuite/app/menu_container.lua:165

local function flushExit()
    if not tool.exitRequested then
        return false
    end

    tool.exitRequested = false
    if system.exit then
        system.exit()
    end
    return true
end

src/ofs3/tools/logs.lua:321