Continue after caller hangs up

In order to update my database with a call log, I need to continue running the dialplan after the caller hangs up. I tried using the ‘g’ parameter in Dial() but this only works if the person being called hangs up the phone. Secondly, I tried using the ‘h’ extension but this only works if the caller hangs up and not the person being called. And…Unfortunately these 2 don’t seem to work together. If I use both, nothing happens and the dialplan stops when the call hangs up. Is there any way around this? Here is a dialplan snippet to hopefully illustrate what I am trying to do.

[code][macro-startCall]

exten => s,1,Answer()
same => n,MixMonitor(${SIPCALLID}.wav)
same => n,Set(CurrentSiteId=${ARG2})
same => n,Dial(SIP/${ARG1}@baldwintelecom,20,g)
same => n,AGI(agi://localhost/createCall.agi?callStatusId=1&webuserId=0&isPriviledged=0&siteId=${ARG2})

;Cleanup extension, this closes the call in the database
exten => h,1,AGI(agi://localhost/createCall.agi?callStatusId=1&webuserId=0&isPriviledged=0&siteId=${CurrentSiteId})
[/code]