Likutei Etzot, Prayer 85
It has already been explained in §34 that all the confusions of thought come upon a person specifically at the time of prayer, and the main thing is to flee from them by sitting still and doing nothing, and not to look behind him at all (as is explained in Thoughts, §8), and through this it will depart of its own accord. And if nevertheless the thought comes upon him once again, he should strengthen himself then too not to look at it at all. And likewise, even if it comes again time after time, if he is strong not to look at it at all in any way, but only to bind his thought to the words of the prayer at which he is standing, then it will certainly depart (and see Thoughts and Musings, §8) (Likutei Moharan II, Torah 51).
View original Hebrew
כְּבָר מְבֹאָר בְּאוֹת ל"ד, שֶׁכָּל בִּלְבּוּלֵי הַמַּחֲשָׁבוֹת בָּאִים עַל הָאָדָם בִּשְׁעַת הַתְּפִלָּה דַּיְקָא, וְהָעִקָּר – לִבְרֹחַ מֵהֶם בְּשֵׁב וְאַל תַּעֲשֶׂה, וְלִבְלִי לְהִסְתַּכֵּל לְאַחֲרָיו כְּלָל (כְּמוֹ שֶׁמְּבֹאָר בְּמַחֲשָׁבוֹת בְּאוֹת ח'), וְעַל־יְדֵי זֶה מִמֵּילָא תִּסְתַּלֵּק. וְאִם אַף עַל פִּי כֵן בָּאָה עָלָיו הַמַּחֲשָׁבָה עוֹד הַפַּעַם, יִתְחַזֵּק גַּם אָז לִבְלִי לְהִסְתַּכֵּל עָלֶיהָ כְּלָל. וְכֵן אֲפִלּוּ אִם בָּאָה עוֹד פַּעַם אַחַר פַּעַם, אִם יִהְיֶה חָזָק לִבְלִי לְהִסְתַּכֵּל עָלֶיהָ כְּלָל בְּשׁוּם אֹפֶן, רַק לְקַשֵּׁר מַחֲשַׁבְתּוֹ לְדִבּוּרֵי הַתְּפִלָּה שֶׁהוּא עוֹמֵד בָּהֶם, אֲזַי בְּוַדַּאי תִּסְתַּלֵּק (וְעַיֵּן מַחֲשָׁבוֹת וְהִרְהוּרִים בְּאוֹת ח'): (לק"ת סי' נ"א)