This is a direct consequence of the divergence theorem. For a vector field $X$ on an oriented $n$-dimensional Riemannian manifold $(M, g)$, the divergence theorem states that $$
\int_M (\operatorname{div} X) dV_g = \int_{\partial M} g(X, N) dV_{\tilde g}$$ where $N$ is the outward-pointing normal vector at the boundary, $dV_g$ is the Riemannian volume form, and $dV_{\tilde g}$ is the induced volume form on the boundary. For a surface embedded in Euclidean space, we use the metric induced by the pullback of the inclusion $i:S \to \mathbb{R}^k$, i.e., $i^*g$ where $g = \delta_{ij}dx^idx^j$ is the usual Euclidean metric. Then $dV_g = ds$ where $ds$ is the area element, and $dV_{\tilde g} = dt$ where $dt$ is a length element. Since the surface in your question is closed, the boundary $\partial S$ is empty and the right-hand side integral is $0$.
If $M$ is not orientable, the divergence theorem still holds if you replace $dV_g$ and $dV_{\tilde g}$ with the respective densities $d\mu_g$ and $d\mu_{\tilde g}$. These densities are nothing but local volume forms on different patches of the manifold glued together with a partition of unity.