We may w.l.o.g. use the musical isomorphism to reformulate OP's question as follows:
Question: Given a nowhere vanishing smooth one-form
$$\omega~=~f\mathrm{d}x+ g\mathrm{d}y~\in~ \Omega^1(\mathbb{R}^2)\tag{1}$$
in the plane$^1$ $\mathbb{R}^2$, does there exist a globally defined smooth integrating factor$^2$ $\lambda$ such that $\lambda \omega $ is an exact one-form $\mathrm{d}h$?
Answer: No, the existence of an integrating factor $\lambda$ is only guaranteed in local neighborhoods.
Counterexample: Ref. 1 shows on p. 53 that the one-form
$$\omega~=~f\mathrm{d}x+ g\mathrm{d}y ~=~y^3(1-y)^2 \mathrm{d}x+ (y^3-2(1-y)^2)\mathrm{d}y\tag{2}$$
has no globally defined smooth integrating factor $\lambda$.
Indirect proof: Assume that there exist $\lambda,h\in C^{\infty}(\mathbb{R}^2)$ such that $$\lambda\omega~=~\mathrm{d}h. \tag{3}$$ Restrict to the open strip $\Omega :=\mathbb{R}\times ]0,1[$. Then
$$ \frac{1}{f}\frac{\partial h}{\partial x}~=~\lambda~=~\frac{1}{g}\frac{\partial h}{\partial y}, \qquad (x,y)~\in~\Omega. \tag{4}$$
Perform bi-smooth coordinate transformation: $\Omega \to \Omega$
$$ (\widetilde{x},\widetilde{y})~=~\left(x+\frac{1}{y^2}+\frac{1}{1-y},y\right)\qquad\Leftrightarrow \qquad (x,y)~=~\left(\widetilde{x}-\frac{1}{\widetilde{y}^2}-\frac{1}{1-\widetilde{y}},\widetilde{y}\right) .\tag{5}$$
Conclude that $h$ does not depend on $\widetilde{y}$:
$$\frac{\partial h}{\partial \widetilde{y}}
~=~\frac{\partial y}{\partial \widetilde{y}}\frac{\partial h}{\partial y}+ \frac{\partial x}{\partial \widetilde{y}} \frac{\partial h}{\partial x}
~\stackrel{(5)}{=}~\frac{\partial h}{\partial y}+ \left( \frac{2}{y^3}- \frac{1}{(1-y)^2} \right) \frac{\partial h}{\partial x}
~\stackrel{(2)}{=}~\frac{\partial h}{\partial y}- \frac{g}{f} \frac{\partial h}{\partial x}
~\stackrel{(4)}{=}~0,\tag{6} $$
i.e. $h$ is only a function of $\widetilde{x}$. Hence $$\lambda ~\stackrel{(4)}{=}~\frac{h^{\prime}(\widetilde{x})}{f}.\tag{7}$$ This leads to the contradiction:
$$ 0~\neq~\lambda(x,y=1)~\stackrel{(7)}{=}~\lim_{y\to 0^+} \frac{h^{\prime}(\widetilde{x})}{f(x,y)}
~=~\lim_{\widetilde{x}\to \infty}\widetilde{x}^{3/2} h^{\prime}(\widetilde{x}),\tag{8} $$
vs.
$$ 0~\neq~\lambda(x,y=0)~\stackrel{(7)}{=}~\lim_{y\to 1^-} \frac{h^{\prime}(\widetilde{x})}{f(x,y)}
~=~\lim_{\widetilde{x}\to \infty}\widetilde{x}^{2} h^{\prime}(\widetilde{x}), \tag{9}$$
$\Box$
References:
- J.B. Boyling, Carathéodory's principle and the existence of global integrating factors, Commun. Math. Phys. 10 (1968) 52. Project Euclid.
--
$^1$ We chose the plane $\mathbb{R}^2$ as an example of a contractible space. It is easy to come up with examples of closed one-forms that are not exact in non-contractible spaces. (OP indirectly asks if it matters if the region is not simply connected? Yes, it does!)
$^2$ An integrating factor $\lambda$ is by definition nowhere vanishing.