I was getting this error message when trying to close the dialog by using a button inside the dialog body. I tried to use $('#myDialog').dialog('close');
which did not work.
I ended up firing the click action of the 'x' button on the header using:
$('.modal-header:first').find('button:first').click();