The while IsMoving loop is not needed here, thats only when Gcode is being executed and you need to wait for it to complete. That probably doesnt hurt anything, since there is nothing moving it falls right thru.
Try the if test like this:
IF Cur_Z_Inhibit then
DoOEMbutton(167)
END IF
TRUE should be 1, but any positive number is OK, so maybe the LED function is returning some other positive number.