Actually David, WebRTC connection should also be included in your statement. If I can re-establish a web socket connection, there should be no reason why I can’t continue to control the established dialog. In my tests i’m able to do this without a problem.
You really should have no reason to close the WebSocket connection. It’s required to be open the entire session, however if a user closes the tab for example, you can fire off code in that event. the onbeforeunload event is called on any browser tab at this moment, and you can use it to terminate any call in place. It will be fire-and-forget because of the asynchronous nature of code, and the server response to this will not reach you, but im sure that’s fine as the call would be ended on the server side, and you page would be unloaded.
In the event that the browser crashes, or there is a power failure, or the user force-quits the application, without this code getting a chance to fire, your best bet is to have rtp_timeout parameter set to something like 120 seconds, so that after 2 min of no audio packets, the call ends. Either way, its pretty messy, and there is little you can do.