If pdx+ qdy is locally exact, then it is, as you say, an exact differential. That means that there exist some function F(x,y) such that dF= pdx+ qdy, at least inside .

But then . Let t be any parameter for the curve and we have where a and b are the beginning and ending values for t. But since this is a closed curve, t= a and t= b give the same point so x(b)= x(a), y(b)= y(a) and F(x(b),y(b))- F(x(a),y(a))= 0.