COMPLETE EDIT: Now that you have removed cohomology and the question has been clarified in my mind, I believe you are asking the following question.
Suppose $\omega$ is a $k$-form with compact support contained in $U$ and there is a smooth form $\beta$ on U with $d\beta=\omega$ on $U$; is $\omega$ globally exact on $M$?
The answer is NO, not necessarily. Consider $M=S^1$, and let $U=S^1-{(1,0)} \cong \Bbb R$. On $\Bbb R$ take a compactly supported function $f$ with integral $1$, and consider $\omega = f(x)\,dx$. This extends to be a smooth $1$-form on all of $S^1$, since $\omega$ is identically $0$ outside a compact subset of $\Bbb R$. $\int_{S^1}\omega = 1$, so $\omega$ cannot be exact. However, on $U=\Bbb R$, we can set $\beta(x) = \int_0^x f(t)\,dt$. By the Fundamental Theorem of Calculus, $d\beta = \omega$ on $U$.