Cleanup on doc window close instead of dealloc