In lots of our unit tests, we want to run the event loop until a certain number of operations are finished. To do this, we count how many are finished, and call event_base_loopexit() when they're done.
Mostly we have to do this because there is some server port that listens for connection attempts, and even when all the test connections are finished, the server event is still listening.
A more elegant solution would be to label some events as "daemon" events. These would share the property with internal events that they do not keep the event_loop from exiting if all the other events are done. The nomenclature is taken from threading libraries that provide a similar feature where the process exits as soon as all non-daemon threads are done running.