How do I find variance from the PSD of a stochastic process?
The factor of $1/\pi$ or $1/(2\pi)$ in front depends on the convention chosen for $S_x$, i.e., one-sided vs two-sided PSD, and also expression of frequency in Hz vs rad/s. Therefore, it's a matter of using consistent conventions between the PSD and the integral. You can check that by seeing if the Wiener-Khinchin theorem is satisfied, https://en.wikipedia.org/wiki/Wiener%E2%80%93Khinchin_theorem.

The bigger issue is the evaluation of the PSD integral near $f=0$, which has to do also with your point about nonstationarity. You need to numerically evaluate the integral over the PSD, which is derived from the DFT of the original signal. The $\mu_x$ term removes the exact $f=0$ term in the DFT. However, there is a subtlety about the low frequency components: in practice, you rarely want to estimate the variance of the entire time-domain signal. I suspect that in applications, you would be more interested in the variance of the signal near the center of your window. Including the window edges will give a lower variance. By limiting the integral as

$\sigma_x(\tau) = \left(\int_{1/\tau}^{\infty} + \int_{-\infty}^{-1/\tau} \right) S_x(f) df$

you effectively detrend the data on timescales below $\tau$.

None of this depends on whether the signal is deterministic vs. stochastic - there's no way for the mathematics to tell the difference.