Problem in session termination

I am working in asterisk version Calls are successfully made using asterisk manager API’s. Normally successful calls are made with proper hangup events. At times the hangup events are received but the session is not terminated by BYE message. So could’nt start a new session. I am using RTC agent and respondent through a third party sip server. Tell me how culd i overcome this problem… Kindly help me.