core.quit() does not mean the next Lua statement cannot execute.
That distinction produced commit e3e21b64:
We need to early-return when quitting since it's not immediate
The rule
If your local control flow must stop, stop it.
if fatalState then
core.quit()
return
end
Do not assume that an engine request has the same semantics as error, return, or process termination.
This generalizes beyond quitting: engine state changes may be scheduled or become visible on a later frame. Read the contract rather than inferring synchronous behavior from the verb.
Source: S3ctors S3cret St4sh commit e3e21b64.