then change YUI first:
YUITerminator::~YUITerminator()
{
    if ( YUI::_ui )
    {
        yuiMilestone() << "Shutting down UI" << endl;
        delete YUI::_ui;

        YUI::_ui = 0;
    }
}