Start the stream with a space-text message, use flush=true to generate buffered text, and end it with an empty text message, which is what actually closes the stream.

Context: Official docs (ElevenLabs streaming reference, elevenlabs/skills repo): the websocket protocol is message driven. Open the stream with a begin message carrying a space as the text, stream your chunks, use flush=true to generate what is buffered immediately, and end the stream by sending an empty text message. The empty text message is what closes things down, it is not a no-op, so dont send it until you are truly done.