We are facing a scenario where we need to be able to control the close of a code snippet session.
Let's say we open a code snippet session, and while it is open, someone alters the state of the document such that it is in a readonly state. The code snippet session would still be open and displayed, when the user is no longer able to edit the document. In this case I would want to close the code snippet session when the the document is changed to a readonly state.
I believe you could close the session when the document is in a readonly state, however it would be far more useful and flexible for us to be able to additionally control the closing from our end as well.