By default the client library closes the connection when the page is closed or refreshed, which will cause the presence members to leave immediately. However, with some combinations of client options, this will not occur.
This can happen if:
- You are using an version of ably-js old enough that closeOnUnload defaulted to false (in which case you should upgrade to the latest version)
- You are using the `recover` client option, and have closed the tab. This option means that the same connection will be resumed after a page refresh (it stores the recovery key in the browser's localStorage), so the same presence members stay the whole time. But that does mean that if you close the tab rather than refreshing, the presence members will stick around in the presence set for 15 seconds (as the client library can not know if the beforeunload event is due to a refresh or a navigation / tab close).
- You are using a browser that does not allow the beforeunload handler enough time to notify the server that the connection is closing when the tab is closed or refreshed. This is the case with some versions of Safari, Internet Explorer, and some other browsers