Setting new default options for jQuery UI widgets

I was messing around with the dialog widget trying to figure out away to have it remove its self after the user closed the dialog.  I tried listening to the dialogclose event but that didn't work.  After playing around with it turns out you can override the default options like so.

$.extend($.ui.dialog.prototype.options, {
        close:function(){
            $(this).dialog('destroy').remove();
        },
        modal: true,
    });

You can override any of the widgets default options by changing ui.dialog to ui.progressbar, ui.datepicker ,etc