Phpagi don't finish when caller hangup

hello, i develop a phpagi aplication, but, when te caller hangup the aplication still running. how i do to stop aplication when the caller hangup. thanks.