Session setHangupHook
About
Sets the hangup callback handler function that will get called when the call terminates.
Remember to call exit() if you want to terminate the javascript session in your hangup callback handler.
Usage
result = session.setHangupHook(hangup_function_name);
NOTE: You MUST declare the hang-up function BEFORE you call the above line, otherwise your hangup hook will not be fired.