/// <include file='doc\VsWindowPane.uex' path='docs/doc[@for="VsWindowPane.ClosePane"]/*' />
        /// <devdoc>
        ///     Called by Visual Studio when it wants to close this pane.  The pane may be
        ///     later re-opened by another call to CreatePaneWindow.
        /// </devdoc>
        public virtual int ClosePane()
        {
            OnWindowPaneClose();

            if (menuService != null)
            {
                menuService.Dispose();
                menuService = null;
            }

            if (helpService != null)
            {
                helpService.Dispose();
                helpService = null;
            }

            if (vsBroadcastEventCookie != 0 && vsShell != null)
            {
                vsShell.UnadviseBroadcastMessages(vsBroadcastEventCookie);
                vsShell = null;
                vsBroadcastEventCookie = 0;
            }

            toolboxService = null;
            host           = null;
            hostChecked    = false;
            return(NativeMethods.S_OK);
        }