close
Close the session, waiting first for any in-flight send to finish.
session.close() writes a close frame and then tears down the same outgoing channel a concurrent send may be writing into. Ktor's byte channels are single-writer — two coroutines mutating one channel's kotlinx.io segment list corrupt it (YouTrack KTOR-7729) — so the close runs under the same sendMutex that serializes frames.
The wait is bounded by CLOSE_QUIESCE_TIMEOUT_MS: a stalled peer must not be able to hold teardown open, and closing is what unblocks a wedged writer.