The lower Limit setting in the advanced mode will stop the bot if losing your next bet will put you below that threshold.

You can configure it in the advanced mode and set "enablesrc=true" in the programmer mode to use that functionality in your script. Be sure to disable any other stop or reset conditions in the advanced mode that you don't want to use, as they will be applied as well. (Resetting in this case reset the built in functions, not your script)
Alternatively, you can just compare your balance- nextbet to your safebank.
if (balance-nextbet<safebank) then stop() end
This will behave the same as the functionality described above.