diff --git a/internal/dispatcher/dispatcher.go b/internal/dispatcher/dispatcher.go index d1a3409..83ec26c 100644 --- a/internal/dispatcher/dispatcher.go +++ b/internal/dispatcher/dispatcher.go @@ -121,7 +121,7 @@ func (d *Dispatcher[T]) run(ctx context.Context) { batch = batch[:0] } - if !ok { + if !ok || d.closed.Load() { // Channel was closed, read all remaining elements and exit return }