diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index dd4949f..a9db920 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -4330,11 +4330,7 @@ static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
This->nsnode_selector = NULL;
}
- if(This->nsdoc) {
- assert(!This->window);
- release_document_mutation(This);
- nsIDOMHTMLDocument_Release(This->nsdoc);
- }else if(This->window) {
+ if(!This->nsdoc && This->window) {
/* document fragments own reference to inner window */
IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface);
This->window = NULL;
diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c
index 42e7c6a..a89b0ca 100644
--- a/dlls/mshtml/htmlnode.c
+++ b/dlls/mshtml/htmlnode.c
@@ -492,6 +492,8 @@ static ULONG WINAPI HTMLDOMNode_Release(IHTMLDOMNode *iface)
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
+ if(This->vtbl->unlink)
+ This->vtbl->unlink(This);
This->vtbl->destructor(This);
release_dispex(&This->dispex);
heap_free(This);