Let $M$ be a smooth manifold, and let $\omega \in \Omega^1(M)$.
Suppose that for every two paths $\gamma_0,\gamma_1:I \to M$ which are homotopic via a homotopy which fixes the endpoints, $ \int_{\gamma_0} \omega=\int_{\gamma_1} \omega$.
Is it true that $\omega$ is closed?
(The converse direction is classic).
By repeating the proof of the converse statement "backwards", one can see that our assumption is equivalent to the the following:
For every homotopy (endpoints fixed) $H:I \times I \to M$, $\int_{I \times I}H^*d\omega=0$.
Yes and it's proved using Stokes theorem.
To check $d\omega =0$, it suffices to check at a fixed point (say, $0$) in a local coordinates $0\in \Omega \subset\mathbb R^n$.
For each $i, j$ fixed and for each $r>0$, let $\gamma_0, \gamma_1$ constitutes the upper and lower semicircle of the circle $C_r$ centered at $0$ in the $i,j$-plane. Then from the condition, for each fixed $r$ we have
$$ \int_{C_r} \omega = 0.$$
By Stokes theorem,
$$ \int_{B_r} d\omega = 0\Rightarrow \int_{B_r} d\omega_{ij} dx^i dx^j = 0.$$
Divide by $\frac{1}{r^2}$ and take $r\to 0$ gives $d\omega_{ij} (0) = 0$. Do this for each $i, j$ gives $d\omega = 0$ at $0$.