Remark. I'm aware that here the same problem is solved. I'm in trouble with the proof I'm going to quote.
Consider the following
Claim. Every closed 1-form $\beta$ on $S^2$ is exact.
This is an exercise from Schutz, Geometrical methods of mathematical physics, ex. 4.24(c). The idea is to construct a function $f$ such that $\beta = \mbox{d} f$. The solutions is as follows.
Solution. We are given $\beta$ defined everywhere on $S^2$ with $\mbox{d} \beta = 0$. Integrate $\mbox{d}\beta$ over any region of $S^2$ bounded by a single closed curve $C$ to find $\oint_C \beta = 0$ for any $C$. This can only be true if $\beta = \mbox{d}f$ for some $f$: otherwise some $C$ can be found on which $\beta$ has nonvanishing integral. In fact $f$ can be constructed by choosing an arbitrary value $f_0$ at a point $P$ and integrating $\beta$ on a curve from $P$ to any point $Q$ definining $$f(Q) = f_0 + \int \beta.$$ The condition $\oint \beta = $ guarantees that $f(Q)$ is independent of the path from $P$ to $Q$.
I can't understand statements emphasized in italics: for the first one, assigned arbitrarly a closed curve $C$ on $S^2$, $C$ is the boundary of some region $U$. Here $\mbox{d}\beta = 0$, hence by Stokes' theorem $\int_U \mbox{d}\beta = \oint_c \beta = 0$. So the $C$ to which the author refers can't be closed, so what's the point?
For the second one, choosing the curve connecting $P$ and $Q$ to be closed, the integral must vanish, hence $f(Q) = f_0$ for any $Q$, being $Q$ arbitrary. Again, I can't see the point here.
Probably, I'm missing something. Might anyone elucidate these arguments to me? Thanks in advance.
What you (and the textbook you are using) are missing is Stokes' theorem for non-simple closed curves $C$ in $S^2$: $\int_C \omega=0$ provided that $\omega$ is a closed 1-form on $S^2$. The curves $C$ appear as concatenations $C= C_1 * C_2$, where $C_1$ is a curve from $P$ to $Q$ and $C_2$ is a curve from $Q$ to $P$. If $\bar{C}_2$ denotes the reverse of the curve $C_2$ then you get: $$ 0=\int_{C} \omega= \int_{C_1}\omega + \int_{C_2}\omega= \int_{C_1}\omega - \int_{\bar{C}_2}\omega. $$ Hence, $$ \int_{C_1}\omega = \int_{\bar{C}_2}\omega. $$ In particular, the integral of $\omega$ is independent of the choice of a curve connecting $P$ to $Q$ (but does depend, of course, on $P$ and $Q$). Note that the curves $C_1, C_2$ could intersect (and in infinitely many point!) which makes $C$ potentially non-simple.
You can reduce this more general Stokes formula for curves with finitely many self-intersections to the case of simple curves by cut-and-paste procedure. However, this will become quite nasty if set of self-intersection points is "large" (e.g. a Cantor set).
Proving the general Stokes formula for non-simple curves hinges on the following property (called simple connectivity): For every closed curve $C$ in $S^2$, regarded as a map $\gamma$ from the unit circle $S^1$ to $S^2$, there exists an extension of $\gamma$ to a map of the unit disk $\Gamma: D^2\to S^2$. (There is an issue of the degree of differentiability of the maps involved, which I am ignoring.) Then the (more general) Stokes theorem states: $$ \int_C \omega:= \int_\gamma \omega= \int_\Gamma d\omega:= \int_{D^2} \Gamma^*(d\omega). $$ If $\omega$ is closed, this integral vanishes: $$ \int_C \omega=0. $$
You can avoid using non-simple curves by restricting integration to arcs of great circles in the 2-sphere.