Sorry i cannot help, when i don't understand what you want. The code works on my server, so no idea what you are doing wrong.
Recopy the code.Only one problem with your script, if i write "/shutdown stop" this will show the sendCancel "numeric param may not be lower than 0"
Recopy the code.
This works, now only the @EDIT error.