Running AGI script on caller hangup event

Hi All,
My environment:
CentOS: 6
Asterisk: 11.16.0

I am building a simple dial plan for post call survey IVR which ask some questions to caller, receive input as DTMF and write that data to a database.
Below is the snippet of my dial plan:
[Survey_Context]
exten => 123789,1,Answer()
exten => 123789,n,Playback(/var/lib/asterisk/sounds/custom/Survey_Welcome)
exten => 123789,n(q1),Read(Res1,/var/lib/asterisk/sounds/custom/Survey_Q1,1,3,5)
exten => 123789,n,GoToIf($[$[${Res1}>0] & $[${Res1}<6]]?q2:loop1)
exten => 123789,n(loop1),Playback(/var/lib/asterisk/sounds/custom/Survey_Rating_Error)
exten => 123789,n,GoToIf($[$[${Res1}>0] & $[${Res1}<6]]?q2:q1)
exten => 123789,n(q2),Read(Res2,/var/lib/asterisk/sounds/custom/Survey_Q2,1,3,5)
.
.
.
exten => 123789,n(bye),Playback(/var/lib/asterisk/sounds/custom/Survey_Goodbye)
exten => 123789,n,AGI(survey.php,${Res1},${Res2},${EXTEN},${UNIQUEID:0:10},${CALLERID(num)},${Res3},${Res4},${Res5},${Comments})
exten => 123789,n,Hangup
Survey.php script connects to a MySQL database and writes data in a table.

Above works fine, but only if caller answers all questions and remains online till end. But if caller decide to answer two questions and then disconnect, that record is missing but I want to record that as well.
I am going thru various blogs and information on net to achieve this and I came to conclusion that I should use h extension to run AGI script, like below:
exten => 123789,n(bye),Playback(/var/lib/asterisk/sounds/custom/Survey_Goodbye)
exten => h,1,AGI(survey.php,${Res1},${Res2},${EXTEN},${UNIQUEID:0:10},${CALLERID(num)},${Res3},${Res4},${Res5},${Comments})
exten => h,2,Hangup
But unfortunately this is not working, means AGI script is not getting called and call completes without running the AGI script.
Please help me out or point me a direction to run AGI script on caller hangup action.

Regards,
Piyush Aghera