Fix possible closed-channel-send panic
Created by: mrnugget
The previous code could cause a panic when ctx.Done()
returns something, the outer function returns, the defer
is triggered and the channel closed and only then the x.pair.Wait()
returns in the goroutine.