How to fix zoom meeting sdk leave infinit redirect

Hi there, we have implemented meeting sdk in react next project. In live website, when host end the meeting, the zoom meeting sdk keeps redirecting constantly and cannot go to leaveUrl… it says socket connection closed and keeps retrying. Browser cancelled the request and it keeps going.

How can we fix it? Is there any ways to programmatically listen for the end event or add some custom button and on click we can end the meeting programmatically and take user to the leave url?