Subroutine error Subroutine call overflow/underflow

I have a question regarding subroutines. The code that I have attached will run for 10 iterations perfectly then I fet the following error:
"Subroutine call overflow/underflow"
If I delete the subroutine, the code works fine. Obviously I am not understanding something about the subroutine command. Could you please enlighten me?
Thanks, Gus Steinmetz

10
begin
dup
while
8000 1 servo
250 delay
4000 1 servo
250 delay
neutral
8000 5 servo
250 delay
4000 5 servo
250 delay
1 minus
Repeat
sub neutral
6000 1 servo
500 delay
6000 5 servo
500 delay
return

Hello,

The problem you’re running into is that once your main loop completes, your program isn’t ending; it’s continuing past the “repeat” into the subroutine. When it reaches the last “return”, there’s nothing to return to, so that causes the “Subroutine call overflow/underflow” error. To fix this, all you need to do is add a “quit” instruction immediately after “repeat”.

- Kevin

Thank you Kevin, that worked perfectly. I’m new to this so I didn’t know about the quit command. The program seems to quit itself if there is no subroutine involved so that confused me.

Gus