If you're trying to close the stream from the receiver then you can cancel the context passed to the stream.
ctx, cancel := context.WithCancel(ctx) stream, err := client.StreamingRPC(ctx) // do something on stream cancel()
Sources: