dialog: check if the transaction is created for BYE closing the dialog

- if not, release the dialog, because there will be no tm callbacks
  called later to release it. In this way avoid zombie dialog.
- reported by Ovidiu Sas, FS#424

(cherry picked from commit 02e43f87b2fa3be61bc4c63a9f8359457e3e0484)
dialog: set again the dialog ids in context for BYE processing

- they can be reset by event route execution

(cherry picked from commit 5b733fa361afced0418947c965b256dbe7ae3a68)