WebKit spends a lot of time in CounterNode::recount() when a Web Inspector window with a long source listing is closed. You should skip all of the counter maintenance when the document is being destroyed and just destroy the counter nodes.
*** Bug 31790 has been marked as a duplicate of this bug. ***