You can't $G($ZEOF) -- you get "Variable expected in this context" from the compiler. This causes the error trap to get invoked, and the error trap is set to "D UNWIND^%ZTER", which ignores the error and makes the interface go back into a listening state without logging an error, which is why we thought it was working.
Since $D seems to be set whenever $ZEOF is set, let's try removing the check for $ZEOF entirely and just check $D. The $EC check should prevent this check from being overly broad.