"Rabbi Ilai, as it is taught in a baraita: Rabbi Ilai says: If a person sees that his evil inclination is gaining control over him and he cannot overcome it, then he should go to a place where he is not known."
"Perhaps these changes will influence him, so that he not sin. Even if these actions do not help, he should at least do as his heart desires in private and not desecrate the name of Heaven in public."
https://www.sefaria.org/Moed_Katan.17a?lang=bi
https://web.archive.org/web/20210110091215/https://www.sefaria.org/Moed_Katan.17a?lang=bi
Moed Katan 17a
Orthodox Judaism