OH3 - Javascript within rule: early return

Nice thinking but the break; in the switch() function will just break out of the switch() function.
If there is code after the switch() then it still gets executed.
It could work if there was nothing after the switch() but the break is not ending the script proper.

example below, the last line get executed no matter what the result of the switch() is

switch (cmd) {
  case "UP": finalcmd = 'm000;'
    break;
  case "DOWN": finalcmd = 'm100;'
    break;
  case "STOP": finalcmd = 's;'
    break;
  default: finalcmd = 'm' + "000".substring(0, 3 - cmd.length) + cmd + ';'
}

cmdtosend = "!" + ba + finalcmd;     <----- This  gets executed  no matter what.