diff --git a/consumer_group.go b/consumer_group.go index 91b6e584e..552da9afb 100644 --- a/consumer_group.go +++ b/consumer_group.go @@ -213,8 +213,11 @@ func (c *consumerGroup) Consume(ctx context.Context, topics []string, handler Co return err } - // Wait for session exit signal - <-sess.ctx.Done() + // Wait for session exit signal or Close() call + select { + case <-c.closed: + case <-sess.ctx.Done(): + } // Gracefully release session claims return sess.release(true)