How do I calculate quantity to minimize long-run average total cost?
Your are right. You have to minimize the average cost.

$$c(Q)=\frac{C(Q)}{Q}=6000 +40Q+Q^2$$

Calculate the first derivative and set it equal to zero:

$ c'(Q)=40+2Q=0 $

Solve this equation for $Q$. Denote the optimal value as $Q^*$. $Q^*$ can be a local maximum or a local minimum

If $c''(Q^*)&gt;0$, then you have found the local minimum.

The local minimum is also the absolute minimum, because

$$\lim_{Q \to \infty } 6000 +40Q+Q^2=\infty$$

$$\lim_{Q \to -\infty } 6000 +40Q+Q^2=\infty$$