1. You don't need the variable, you can use directly
$DLG_timeout = 10;
2. How do you check if the dialog is deleted or not? Are you
using the dlg_list command? If you also want to send BYE
messages to your clients, you should use the 'B' flag when
creating the dialog.