NPError NPP_DestroyImpl(NPP instance, NPSavedData** save) { ClientPlugin* plugin = reinterpret_cast<ClientPlugin*>(instance->pdata); if (plugin) { if (g_offscreenBrowser.get()) { CefRefPtr<ClientOSRHandler> handler = static_cast<ClientOSRHandler*>(g_offscreenBrowser->GetClient().get()); handler->Detach(); } if (plugin->hWnd) { DestroyWindow(plugin->hWnd); DisableGL(plugin); } delete plugin; } return NPERR_NO_ERROR; }