Summary: This will be my second post I think that actually has nothing to do with neurons.
When worms defecate, they apparently have a very characteristic body pattern consisting first of posterior contraction (both dorsal and ventral), followed by anterior contraction (again, both dorsal and ventral) followed by expulsion. Subdividing this process into these three steps (called pBoc, aBoc and Exp) goes back to at least (Thomas, Genetics, 1990). In this paper, they refer to this as the defecation motor program (DMP).
This process occurs via a calcium wave that starts in the posterior intestinal cells and propagates via innexins to the anterior intestinal cells. I have some questions about this* but I'll hold off on them for now. The calcium influx into these intestinal cells induces pumping protons from the intestinal cells into the pseucoelomic space and acidifying it. Body wall muscles then respond to this acidication via proton-gated ion channels (PBO-5/6) and contract.