[smartymixed mode] Fix regexp escaping

Issue #2659
Move update of delayedCallbackDepth to start of endOperation

To make it less likely that an error will corrupt its value and
break all further signalLater events.

Issue #2626