title: Boost asio handler that does not keep the io_service running
body: <p>I want to add a signal handler to my boost io_service, allowing the application to shut down cleanly when the user presses Ctrl-C. This is of course easily done by stopping the loop, something like this:</p>
  
  <pre><code>boost::asio::io_service service;
  boost::asio::signal_set signals{ service, SIGINT, SIGTERM };
  
  signals.async_wait(std::bind(&amp;boost::asio::io_service::stop, &amp;service));
  </code></pre>
  
  <p>This stops the loop normally, allowing the destructors to do their routine clean-up behaviour.</p>
  
  <p>The problem is, once the application runs out of work it does not stop because the signal handler still has a handler registered and thus the io_service never stops running.</p>
  
  <p>I have not found a clean way around this. I could of course do the signal handling myself and then just stop the loop, but this kind of defeats the idea of using boost (portability).</p>