Q : "How to exit endless zmq_poll when host ip address changes?"
The best approach is to never admit a piece of code that lets you loose the control of the flow of work.
TL;DR;
Accepting a code, where you realise to become powerless & ultimately dependent on some (potentially never coming) external stimulus, well, one need not be an Apollo Guidance Computer designer, yet one shall never dare to put such piece of code in Production. Willing to take a lesson on critical-systems design? Feel free to read anything available from Ms. Margaret HAMILTON, the NASA APOLLO Programme hero, who saved the crew from crashing into the Moon surface. Lifelong lessons come from the mastery of this smart & brave lady performed some 60 years ago already.
The best approach :
Design for a chance to self-adapt ( having a Darwin in mind ).
Declare all the use-cases of zmq_poll() having some stability-related control-loop latency for idle-cycles (where no events get flagged in), say 100 ms to have about a ~ 10 Hz or 10 ms to have about a ~ 100 Hz strobe for your known control-loop stability threshold, and use your idle-loop time for detecting and soft-signalling of any and all such important changes into your code, that will thus get chance to knowingly self-adapt to them per-incident.
Self-adaptation to a changed interface addresses (a live-system manual IP-address change being one such) should, as an example of good design-practice, also de-commission all so far active (now dead) .bind()-s, as these might otherwise intervene with some round-robin and fair-queue based Socket()-instances' methods, now potentially waiting infinitely on deaf ends etc.)
The list of such countermeasures would be endless here, yet the philosophy of designing non-blocking, self-adaptive code is the same.
Assume problems to be sure they will come, the only thing we do not know is, when they come, from which direction and how often we will have to bother to have to cope with them.
The rest is yours :o)