If $M$ is of dimension $<4$ then the answer is YES because there are no exotic structures on $M$ and there are full classification results.[EDIT: In case of 3-manifolds this is true except some surface bundles over $S^1$ with fiber genus $>1$ and periodic monodromy, Stability of 3-manifolds.]
It is not true in dimension 4. For example, any closed simply-connected 4-manifold $M$ and an 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). This is then a trivial cobordism by the high-dimensional s-cobordism theorem which says that such an h-cobordism is trivial if the Whitehead torsion of $\pi_1(M\times S^1)$ vanishes and indeed $Wh(\pi_1(M\times S^1))= Wh(\mathbb Z)=0$ by a result of Bass. So they are in fact diffeomorphic.
When the dimension is $>4$ the answer is YES if $M$ is simply-connected. To see this, notice that it is enough to show that $M$ and $M'$ are h-cobordant. Since $M\times S^1$ is diffeomorphic to $M'\times S^1$ there is a map $f:M \to M'\times S^1$. Since $M$ is simply-connected $f$ has a lift $\bar{f}$ to the universal cover $M'\times \mathbb R$. We claim that the image of $\bar{f}$ separates $M'\times \mathbb R$. Otherwise we can cut $M'\times \mathbb R$ along $Im(\bar{f})$ and connect the two boundary components by an arc $\gamma$. This arc in the original manifold $M'\times \mathbb R$ gives rise to a closed curve $\gamma'$ which transversally intersects $Im(\bar{f})$ at a single point. But $M'\times \mathbb R$ is simply-connected and thus $\gamma'$ is homotopic to a point disjoint from $Im(\bar{f})$, contradicting the homotopy-invariant count of transverse intersection points. Now, since $M$ is compact we can find a cobordism from $Im(\bar{f})\approx M$ to $M'\times \{t\}$ for some sufficiently large $t\in \mathbb R$. Since everything is simply-connected and the projection map induces isomorphisms on homologies, by Hurewitz' theorem we can conclude that this is an h-cobordism and so $M$ is diffeomorphic to $M'$.