It moved to after the if statement for the error condition.  There were other small issues with the NIF env having free/new instead of clear and missing the zmq msg close.