Exit the whole script

i have a function like this

function main
put sub1
put sub2
put sub3
end main

function sub1
// an error is encountered here.
end sub1

function sub2
end sub2

function sub3
end sub3

Main function is executed. When an error is encountered in function sub1, how to stop the script? It should not execute function sub2 and function sub3

You can use the code:

exit all

to exit the script entirely at any point.