Fix a file descriptor leak in BackgroundEventLoop.
Only tell processes to shut down after all sessions have closed.