Before each motor on command (motorx=1) add
if run = 0 then goto main

That way, If run gets set to 0 while in the run=1 loop, it can get out before turning any motors on