Noob who wants a script to execute on hang up

Assume I’m a noob.

I want to call a shell script when a specific extension (21) hangs up on an outgoing call.

I’m using
Your Linux Distribution: (Redhat CentOS release 6.3 (Final))
Your FreePBX version: (2.8.1)

it looks like I can do this from /etc/asterisk/extension_custom.conf with a system call.

Permissions (for testing) of the script are 777.

but I’ve looked around and I just can’t make it work.

Keep in mind that everything I’ve done before this has been through the web gui, so I am really over my head doing this by hand.

If someone could point me in the right direction, that would be grand.

What type of telephones are you using?
Some have an Action URI or Action URL that could be used to call a script when the handset is hung up.