There is a problem when text is processed multiple times and this of course happens when \mathpalette is involved.
If you try
\documentclass{article}
\usepackage{amsmath}
\newcounter{noi}
\newcommand{\doit}{\stepcounter{noi}x}
\begin{document}
$\sqrt[3]{\doit}$
Number of instances: \thenoi
\end{document}
(note the optional argument) you get 4 as the number of instances. You'd get just 1 with \sqrt{\doit}.
In the case of the closed square root symbol, the optional argument is always assumed, so the routine is called four times because \mathpalette enters into action.
You can greatly reduce the amount of stepping by loading amsmath (well, amstext) and redefining \mathpalette to set \iffirstchoice@. The package redefines \stepcounter and \addtocounter to do nothing when \iffirstchoice@ returns false. This is used in \text for avoiding to step counters four times. However, \mathpalette is not redefined, so we need to. Also, \firstchoice@false must be issued when the argument possibly containing counter stepping is subject to trial typesetting.
Note that this just turns off excess stepping, not the number of times the boxes are typeset (which is indeed 20).
\documentclass{article}
\usepackage{mathtools}
\usepackage{xparse}
\usepackage{letltxmacro}
\makeatletter
\def\mathpalette#1#2{%
\mathchoice
{#1\displaystyle{#2}}%
{\firstchoice@false#1\textstyle{#2}}%
{\firstchoice@false#1\scriptstyle{#2}}%
{\firstchoice@false#1\scriptscriptstyle{#2}}}
\makeatother
\LetLtxMacro{\oldsqrt}{\sqrt}
\makeatletter
\newcommand{\ClosedSqrt}[1][]{\def\DHLindex{#1}\mathpalette\DHLhksqrt}%
\def\DHLhksqrt#1#2{%
\sbox0{\firstchoice@false$#1\oldsqrt{#2\,}$}\dimen0=\ht0\relax
\advance\dimen0-0.25\ht0\relax
\sbox2{\kern-0.375pt\vrule height\ht0 depth -\dimen0}%
{%
\hbox{$#1\expandafter\oldsqrt\expandafter[\DHLindex]{#2\,}$}%
\lower\ifx\math@version\bold@name0.60pt\else0.4pt\fi\box2
}%
}%
\RenewDocumentCommand{\sqrt}{O{\hphantom{3}} O{0} O{0} m}{\ClosedSqrt[\leftroot{#2}\uproot{#3}#1]{#4}}%
\newcounter{NumberOfInstances}
\setcounter{NumberOfInstances}{0}
\newcommand*{\MyValue}{%
\stepcounter{NumberOfInstances}%
x%
}%
\makeatother
\begin{document}\noindent
NumberOfInstances=\arabic{NumberOfInstances}.
\[ \sqrt{\MyValue} \]
NumberOfInstances=\arabic{NumberOfInstances}.
\[ \oldsqrt[3]{\MyValue} \]
NumberOfInstances=\arabic{NumberOfInstances}.
\end{document}

For reducing the stepping to one, you need to also modify the definition of \r@@t.
\documentclass{article}
\usepackage{mathtools}
\usepackage{xparse}
\usepackage{letltxmacro}
\makeatletter
\def\mathpalette#1#2{%
\mathchoice
{#1\displaystyle{#2}}%
{\firstchoice@false#1\textstyle{#2}}%
{\firstchoice@false#1\scriptstyle{#2}}%
{\firstchoice@false#1\scriptscriptstyle{#2}}}
\def\r@@t#1#2{%
\ifx#1\displaystyle\else\firstchoice@false\fi
\setbox\z@\hbox{$\m@th#1\sqrtsign{#2}$}%
\dimen@\ht\z@ \advance\dimen@-\dp\z@
\mkern5mu\raise.6\dimen@\copy\rootbox
\mkern-10mu\box\z@}
\makeatother
\LetLtxMacro{\oldsqrt}{\sqrt}
\makeatletter
\newcommand{\ClosedSqrt}[1][]{\def\DHLindex{#1}\mathpalette\DHLhksqrt}%
\def\DHLhksqrt#1#2{%
\sbox4{\firstchoice@false$#1\oldsqrt{#2\,}$}\dimen0=\ht4\relax
\advance\dimen0-0.25\ht0\relax
\sbox2{\kern-0.375pt\vrule height\ht0 depth -\dimen0}%
{%
\hbox{$#1\expandafter\oldsqrt\expandafter[\DHLindex]{#2\,}$}%
\lower\ifx\math@version\bold@name0.60pt\else0.4pt\fi\box2
}%
}%
\RenewDocumentCommand{\sqrt}{O{\hphantom{3}} O{0} O{0} m}{\ClosedSqrt[\leftroot{#2}\uproot{#3}#1]{#4}}%
\newcounter{NumberOfInstances}
\setcounter{NumberOfInstances}{0}
\newcommand*{\MyValue}{%
\stepcounter{NumberOfInstances}%
x%
}%
\makeatother
\begin{document}\noindent
NumberOfInstances=\arabic{NumberOfInstances}.
\[ \sqrt{\MyValue} \]
NumberOfInstances=\arabic{NumberOfInstances}.
\[ \oldsqrt[3]{\MyValue} \]
NumberOfInstances=\arabic{NumberOfInstances}.
\end{document}

$\frac{\MyValue}{1}$does not have such a problem. Doesn't\frac{}{}goes through a similar process to decide how the fraction should be typeset? – Peter Grill Dec 17 '15 at 07:06\measuring@is thought out to be set. And anyhow if I do not loadmathtoolsat all comment out the\leftroot,\uproot, and\ifmeasuring@things, I again get20with your code. – Dec 17 '15 at 07:49\mathchoicecommand (called by\mathpalette) typesets four boxes. Five calls of\mathchoicemake for twenty boxes; the original\sqrtcommand (when the optional argument is used) calls\mathpaletteand so does\phantomin math mode. – egreg Dec 17 '15 at 07:49\measuring@is not set. I want to be able to set it so that I can disable the counting during that phase. – Peter Grill Dec 17 '15 at 07:51\saveboxfirst. – Peter Grill Dec 17 '15 at 07:52mathstylepackage to get an expandable\mathchoice. – Manuel Dec 17 '15 at 10:22