If you're using the javascript client, ably-js, you may have noticed that if you close a tab (or refresh the page etc.), it takes 15 seconds for any members which were present on a connection on that tab to leave the presence set. This is because Ably expects that the abruptly disconnected connection could later be recovered, so does not immediately remove the user from presence, to avoid “twitchy” presence behavior in case the user reconnects after a few seconds, using Ably's connection state recovery.

If you don't want this behaviour, you can disable it with the closeOnUnload client option, which causes the client to send a close request to Ably in the window.beforeunload event. This will mean the connection state will not be retained, and any presence members associated with that connection will leave immediately.

Another option is to use the recover client option. This will cause the same connection to be resumed after a page refresh (it stores the recovery key in the browser's localStorage), so the same presence member stays the whole time - it isn't replaced by a new one. So in a sense this solves the problem in the opposite way: reusing the same connection, rather than promptly closing the old and starting a new. See an example of this here. Note that while this option solves the doubling up presence members after a refresh, if the user closes the tab, they 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).