Zend certified PHP/Magento developer

Asterisk: how to end frozen calls

Sometimes my voip provider shuts down service without ending calls which are in progress (these calls are incoming to my server and they are coming to queue).
So calls are never gracefully finished, I never get BYE and I have my peers in queue keep being in “in call” state forever. I can only reset their state by restarting asterisk service.

How do I set up asterisk to end this kind of calls automatically? Is there some kind of timeout for this situation?