I see your talking Asterisk. Indeed,
exten =>D,n,Hangup()
works. In fact I'm doing something similar to catch hangups before the call is bridged to the voicemail application. The problem is when the call is bridged (in asterisk) to app_voicemail.so there are 2 pointers passed to the recording function,
char *acceptdtmf = "#";
char *canceldtmf = "";

I could simply change the # to D, however this machine does much more than be a Toshiba Voicemail system so I am working on a patch to have the vm-app accept an extra option (without rewriting the whole program). This is still not going to be a perfect solution as those 2 parameters are not perfect matches to the dtmf A & D functionality.

At any rate, the best solution would be to have the toshiba hang up without sending tones of any type when the call terminates. And for the purposes of this discussion, I am regading it as a Toshiba question (I'll share the patch and voicemail contexts - but should get it working first).