IAX client - how to detect disconnection?

How could an IAX client know if it gets disconnected in any reason from Asterisk?