If $M$ is of dimension $<4$, then the answer is YES as there is no exotic structures on $M$ and classification results are well studied.
It is not true in dim 4. For example,
Any closed simply-connected 4-manifold $M$ and its exotic copy $M'$ are h-cobordant by a theorem of Wall. Thus $M\times S^1$ is h-cobordant to $M'\times S^1$ (as one can extend the previus h-cobordsim trivially on the $S^1$ component). Which is trivial by high dimensional s-cobordism theorem which says that such a cobordism is trivial if Whitehead torsion of $\pi_1(M\times S^1)$ vanish (https://en.wikipedia.org/wiki/H-cobordism#The_s-cobordism_theorem) and $Wh(\pi_1(M\times S^1))= Wh(\mathbb Z)=0$ by a result of Bass (http://www.numdam.org/item/?id=PMIHES_1964__22__61_0). So they are in fact diffeomorphic.
When the dim of $M$ is $>4$ then the answer is YES if $M$ is simplyconnected.
To see this notice that it is enough to show that $M$ and $M'$ are h-cobordant. We know that $M\times S^1$ is diffeomorphic to $M'\times S^1$. So there is a map $f:M \to M'\times S^1$. As $M$ is simplyconnected $f$ has a lift $\bar{f}$ to the universal cover $M'\times \mathbb R$. Image of $\bar{f}$ separating $M'\times R$ and given the fact that $M$ is compact, we find a cobordism from $img(\bar{F})=M$ to $M'\times \{t\}$ for some sufficiently large $t\in \mathbb R$. Notice that as everything is simplyconnected and projection map induces isomorphisms on homologies, so by Hurewitcz's theorem we can conclude that this is an h-cobordism and thus $M$ and $M'$ are diffeomorphic.