You have the right idea, but it seems you don't know $\mu$, so using it in your error check doesn't seem correct. Also, checking the result every 10,000 iterations may not be optimal for deciding when to stop.
To be clear, let $E(X) = \mu$ and $Var(X) = \sigma$. We're invoking the CLT when we write
$$
P\left( \left|\frac{\bar{X}_n - \mu}{\sigma/\sqrt{n}}\right| > 1.96 \right) \approx P(|Z| > 1.96) = 0.05.
$$
In words, there is approximately a 95% probability that the sample mean $\bar{X}_n$ is within $1.96\frac{\sigma}{\sqrt{n}}$ units of the true mean $\mu$.
How do we use this in simulation? First, note
$$
S_n^2 := \frac{1}{n-1}\sum_{i=1}^n (X_i - \bar{X})^2
$$
is an unbiased estimator of $\sigma^2$. Thus if we want an approximate 95% probability that $\bar{X}_n$ is within $0.01$ units of $\mu$, we continue simulation until
$$
1.96\frac{S_n}{\sqrt{n}} < 0.01.
$$
There are two important items to note:
- We should have $n \geq 30$ to use this error check since this is a result of the CLT, and
- An online implementation of $\bar{X}_n$ and $S_n^2$ would be much more efficient, so that we don't recompute them every time.
For item 2, we may use
\begin{align}
\bar{X}_{n+1} & = \bar{X}_n + \frac{X_{n+1} - \bar{X}_n}{n+1}, \\
S^2_{n+1} & = \left(1 - \frac{1}{n}\right)S_n^2 + (n+1)(\bar{X}_{n+1} - \bar{X}_n)^2
\end{align}
Now we may simply use a while
($1.96\frac{S_n}{\sqrt{n}} > 0.01$) loop, stopping at exactly the iteration this error is met.