If you use ZMQ, and am wondering why you are experiencing hanging when when you exit the program, it’s because the default LINGER value for your socket is set at infinity. When closing the context, the program hangs at the context termination routines.
You need to do this.
// Configure socket to not wait at close time
int linger = 0;
yoursocket->setsockopt (ZMQ_LINGER, &linger, sizeof (linger));
Otherwise, you might run into cases where the context termination routine is waiting for the socket to close. The socket will be blocking still at a function say, socket.recv() and will be unable to unblock unless ZMQ_LINGER is set to 0.
NOTE: Bindings such as CZMQ may have already done this for you.