Terminating delivery manager when all producers are stopped, and queue is empty and all consumers are stopped