My question is: how can we unload a plugin when the plugin is running?

I have below code which runs on WindowsXP. the iUpgrade->performUpgrade() may dead sometimes. so I guess I'll need to unload the plugin dll to let the main application quite successfully. But when I can loader->unload() from within some other funtion, the application crashed.
======================
QPluginLoader *loader; //loader pionter saved as class private member
...
...

loader = new QPluginLoader (dir.absoluteFilePath(fileName));
QObject *plugin = loader->instance();

if (plugin)
{
UpgradeInterface * iUpgrade = qobject_cast<UpgradeInterface *>(plugin);
if (iUpgrade)
{
iUpgrade->performUpgrade();
}

loader->unload();
}
}