First note that if $g_{i,q+1}:\Bbb R^n\to\Bbb R$ is any constant function with positive value,
$$\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}=\bigcap_{j=1}^{q+1}\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\;,$$
since
$$\begin{align*}
\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{i,q+1}(x)>0\right\}&=\left\{x\in\Bbb R^n:f_i(x)=0\right\}\\
&\supseteq\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\;.
\end{align*}$$
Suppose that
$$S=\bigcup_{i=1}^p\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_{i}(x)=0\text{ and }g_{ij}(x)>0\right\}$$
and
$$T=\bigcup_{i=1}^r\bigcap_{j=1}^s\left\{x\in\Bbb R^n:h_{i}(x)=0\text{ and }k_{ij}(x)>0\right\}\;.$$
Without loss of generality assume that $q\le s$. If $q<s$, let $g_{ij}$ be a positive constant function for each $i=1,\dots,p$ and $j=q+1,\dots,s$; by the previous observation we may then write
$$S=\bigcup_{i=1}^p\bigcap_{j=1}^s\left\{x\in\Bbb R^n:f_{i}(x)=0\text{ and }g_{ij}(x)>0\right\}\;.$$
Now for $i=1,\dots,r$ and $j=1,\dots,s$ let $f_{p+i}=h_i$ and $g_{p+i,j}=k_{ij}$; then
$$S\cup T=\bigcup_{i=1}^{p+r}\bigcap_{j=1}^s\left\{x\in\Bbb R^n:f_{i}(x)=0\text{ and }g_{ij}(x)>0\right\}\in\mathcal{S}\;,$$
and an easy induction shows that $\mathcal{S}$ is closed under finite unions.
To show that $T\cap S\in\mathcal{S}$, note first that
$$\begin{align*}
&T\cap\bigcup_{i=1}^p\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_{i}(x)=0\text{ and }g_{ij}(x)>0\right\}\\
&\qquad\quad=\bigcup_{i=1}^p\left(T\cap\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\right)\;,
\end{align*}$$
so it suffices to show that
$$T\cap\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\in\mathcal{S}$$
for $i=1,\dots,p$. This in turn will follow by an easy induction if we can show that
$$T\cap\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\in\mathcal{S}$$
for a fixed $i$ and $j$. But
$$\begin{align*}
&T\cap\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\\
&\qquad=\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\cap\bigcup_{i=1}^r\bigcap_{j=1}^s\left\{x\in\Bbb R^n:h_{i}(x)=0\text{ and }k_{ij}(x)>0\right\}
\end{align*}$$
is a finite union of sets of the form
$$\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\cap\bigcap_{j=1}^s\left\{x\in\Bbb R^n:h_{i}(x)=0\text{ and }k_{ij}(x)>0\right\}\;,$$
which clearly belong to $\mathcal{S}$, so indeed
$$T\cap\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\in\mathcal{S}$$
and hence $T\cap S\in\mathcal{S}$.
$$\begin{align*}
\Bbb R^n\setminus S&=\Bbb R^n\setminus\bigcup_{i=1}^p\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_{i}(x)=0\text{ and }g_{ij}(x)>0\right\}\\
&=\bigcap_{i=1}^p\bigcup_{j=1}^q\left\{x\in\Bbb R^n:f_i(x)\ne 0,\text{ or }g_{ij}(x)\le 0\text{ for some }j\right\}\;,
\end{align*}$$
so by what we’ve already done it suffices to show that each
$$\left\{x\in\Bbb R^n:f_i(x)\ne 0,\text{ or }g_{ij}(x)\le 0\text{ for some }j\right\}\in\mathcal{S}\;.$$
The set $$\left\{x\in\Bbb R^n:f_i(x)\ne 0,\text{ or }g_{ij}(x)\le 0\text{ for some }j\right\}$$
is the union of the following sets:
$$\begin{align*}
&\left\{x\in\Bbb R^n:f_i(x)>0\right\}\;,\\
&\left\{x\in\Bbb R^n:f_i(x)<0\right\}=\left\{x\in\Bbb R^n:-f_i(x)>0\right\}\;,\\
&\left\{x\in\Bbb R^n:g_{ij}(x)=0\right\}\;,\text{ and}\\
&\left\{x\in\Bbb R^n:g_{ij}(x)<0\right\}=\left\{x\in\Bbb R^n:-g_{ij}(x)<0\right\}\;.
\end{align*}$$
Can you show that each of them is in $\mathcal{S}$ and hence that their union is as well?