When the subroutine written in BASIC ends (either by hitting the end of the source code or by explicitly executing the END statement) it returns to the calling program. (If you try to use an extra RETURN, like you would in a subroutine written in M68 assembler, you will get BASIC error “return without gosub.”)
If you want to abort directly to the monitor level (aka “dot prompt”) rather than return to the calling program, use the following routine:
xcall MIAMEX,MX_EXIT ! abort to 'dot prompt'
Note that this is analogous to the use of the EXIT monitor call under the AMOS assembler.