[Toggle] will always branch to either goto [On] or goto [Off}, but neither of them are called using gosub and return, so why doesn't [On] drop on through into [Off] or [Off] drop out to end the program, and what decides where the program flow goes to from the bottom of such branches?
cls
let OutputPin = D4
button "Toggle" [Toggle]
wait
[Toggle]
if PinStatus == 1 then goto [On] else goto [Off]
[On]
PinStatus = 0
po OutputPin 1
wait
[Off]
PinStatus = 1
po OutputPin 0
wait