Asterisk executing DeadAGI on h extension before hangup

Hi all,

I have the following scenario:

  1. Manager originate to a Local/ extension, which executes an AGI
  2. AGI executes DIAL command

Once the call is answered, my AGI script terminates, which is fine for me. Hwever, Asterisk executes the DeadAGI on the h extension, because of that.

The strange thing is, the call itself works fine.

Any ideas why? How do I wait in my AGI for the call to finish, if that is required?

Best regards,