$\int_{\lambda}w$ constant for any closed path $\lambda$, then $w$ is a closed $1$-form 
Let $w$ be an $1$-form of class $C^1$ in the open ball $B\subset
 \mathbb{R^m}$, such that the integral $\int_{\lambda}w$ is a constant
  for any closed path $\lambda$, sectionally $C^1$, contained in $B$.
  Prove $w$ is closed.

Definition: a $1$-form $w = \sum a_i dx_i$, of class $C^1$, is closed when $$\frac{\partial a_i}{\partial x_j} = \frac{\partial a_j}{\partial x_i}$$
If $w = \sum a_i dx_i$, $w$ is exact when $a_i = \frac{\partial f}{\partial x_i}$ for $i=1,\cdots, n$
My book then says that every exact form of class $C^1$ is closed. Why? 
Anyways, since $\int_\lambda w$ is constant for any closed path, I think this result has something to do with $w$ being closed because of vector space integration, but I'm unable to explain why. Also, $\lambda$ is sectionally $C^1$, not exactly $C^1$, but I know I can separate the integral in each part and end up with integrals along $C^1$ paths.
 A: This answer is based on @user90189's comment and to Gio67's answer. 
Let $C=\int_\gamma \omega$ be the constant given in the text. That is, $C$ is independent on $\gamma$. 
First step: show that $C=0$. To do that consider a small loop $\gamma_\epsilon$ of length $\epsilon$ and show that 
$$
|C|= \left\lvert \int_{\gamma_\epsilon} \omega \right\rvert \le \| \omega\| \epsilon, $$ 
where $\|\omega\|$ is some number that depends on $\omega$ only. 
Second step: show that the property $\int_\gamma \omega = 0 $ for all closed loops $\gamma$ implies that $\omega$ is exact, in the sense that there exist functions $f\colon B\to \mathbb R$ such that 
$$\tag{1}
\frac{\partial f}{\partial x_i} (x) = a_i(x),\qquad i=1\ldots m.$$
And this is something that's done on all textbooks and also in Gio67's answer. However, this is often done using the assumption that $\omega$ is closed, which is exactly what we are trying to prove. So we need to take another route, which a posteriori will turn out to be equivalent. I suggest the following (which is in the textbook "Div, Grad, Curl and all of that", by Schey). 
Let $x\in B$. Note that, if $\gamma_x, \tilde{\gamma}_x\colon [0, 1]\to B$ are paths such that $\gamma_x(0)=(0, \ldots , 0)$ and $\gamma_x(1)=x$, one has 
$$
\int_{\gamma_x}\omega= \int_{\tilde{\gamma_x}}\omega, $$
because if one joins the two paths they form a closed loop. So we can define a function 
$$f(x)=\int_{\gamma_x}\omega, $$ 
without specifying the precise path. This is useful, because now we want to compute $\frac{\partial f}{\partial x_1}$. To do so we take a path $\gamma$ that is constructed by joining the two paths 
$$
\begin{array}{ccccc}
\gamma_1 & \text{which joins} & (0,\ldots, 0 ) & \text{and} & (0, x_2, \ldots, x_m) \\
\gamma_2 & \text{which joins} & (0, x_2, \ldots, x_m ) & \text{and} & (x_1, x_2, \ldots, x_m).
\end{array}
$$
Then $f(x)= \int_{\gamma_1}\omega + \int_{\gamma_2}\omega$ and since the first integral is independent of $x_1$, 
$$
\frac{\partial f}{\partial x_1} = \frac{\partial}{\partial x_1} \int_{\gamma_2}\omega = \frac{\partial}{\partial x_1} \int_0^{x_1} a_1(t, x_2\ldots x_m)\, dt.$$
And now we conclude by using the fundamental theorem of calculus. The other derivatives are computed similarly. We remark that the invariance of the integrals on the path is fundamental here, as one needs to take a path for each coordinate direction. 
Third and final step. Show that the existence of a function with property (1) implies that $\omega$ is closed. This is an application of Schwarz's theorem on the equality of mixed derivatives.
