Add end handling to node wrapper