It is always better to close the connections whenever the chat function is not in use. This helps in preventing overage. The overage is calculated when concurrent connections / MAU / message count exceeds the plan. A common problem is the concurrent connections where users log in from different systems and leave the connections open. Remember, any active WebSocket connection counts to concurrent connection. So it is always better to terminate/disconnect the connection when not in use.
Here is the best practice -
Try to disconnect the client on each page load to avoid holding a reference to it on previous pages -
A disconnect can be triggered by calling the below function -