title: Kotlin wait for Channel.isClosedForReceive
body: <p>After calling <code>Channel.close()</code> what is the best way to wait for <code>Channel.isClosedForReceive</code> to be true? </p>
  
  <p>I'm processing messages in order and would like to return the max message processed after calling <code>Channel.close()</code>. However, if I just take the max processed message after calling <code>close()</code> there may be some messages in the channel before the "close token" is consumed causing the real max processed message to be greater then the value returned.</p>
  
  <p>Based on the doc for <code>Channel.close()</code> I think Channel.isClosedForReceive is what I should be waiting for. But I was expecting some suspend function to wait, rather then having to poll its status.</p>
  
  <pre><code>/**
   * Immediately after invocation of this function
   * [isClosedForSend] starts returning `true`. However, [isClosedForReceive][ReceiveChannel.isClosedForReceive]
   * on the side of [ReceiveChannel] starts returning `true` only after all previously sent elements
   * are received.
   **/
  </code></pre>