title: How to terminate a process with a ZeroMQ socket that has been closed?
body: <p>I'm making a publish subscribe using ZeroMQ. Here is a simplified code :</p>
  
  <pre><code>import zmq from 'zeromq';
  import d from 'debug';
  
  const debug = d('publisher');
  
  let port = '8000';
  let subject = 'FLIGHTS';
  
  const socket = zmq.socket('pub');
  
  socket.on('close', function(...toto) {
    debug('connection closed');
  });
  socket.on('close_error', function(...toto) {
    debug('error while closing connexion');
  });
  
  socket.monitor(10, 0);
  socket.bindSync('tcp://*:' + port);
  
  export function send(message: object) {
    const jsonMessage = JSON.stringify(message);
    socket.send([subject, jsonMessage]);
  }
  
  export function close() {
    socket.close();
  }
  
  setTimeout( () =&gt; close(), 3000 );
  </code></pre>
  
  <p>The problem I have is that the process won't exit even if the socket is closed after 3 seconds. I can't use <code>process.exit</code> because the module I'm making is used in a lot a jest tests.<br>
  I didn't find anything in the <a href="http://zeromq.github.io/zeromq.js/" rel="nofollow noreferrer">ZeroMQ documentation</a>.</p>