You can’t stop thoughts from entering you. They will enter you non-stop, but you can discriminate and discern what types of thoughts enter your mind and heart.
Do not let thoughts, originating from evil, enter your mind and heart. In order to do this, you need the gift of discrimination: also called the gift of discernment or distinguishing.
Apostle Paul writes that the gifts of the Holy Spirit are many and they all work for the common good. He mentions the gift of distinguishing between spirits, writing “to another the working of miracles, to another prophecy, to another the ability to distinguish between spirits, to another various kinds of tongues, to another the interpretation of tongues.” 1 Corinthians 12:10
The church fathers consider this gift a very important gift in order for you to discern between the thoughts and ideas that enter your mind and heart. John Cassian writes in Philokalia that the gift of distinguishing between the spirits is given only to those who desire true humility. This gift is given so that we do not trust our own thoughts and do not follow evil desires, but follow the guidance of the Holy Spirit.
Through wisdom a house is built, through understanding it is established, and through good judgment its storehouses will be filled with wealth’ (Prov. 24:3-4. LXX). St. Antony the Great, referring to this and several other passage from the Holy Scripture writes that “these passages show very clearly that without the gift of discrimination no virtue can stand or remain firm to the end, for it is the mother of all the virtues and their guardian.”
Desire to live your lives in true humility. And as Apostle John writes: “Dear friends, do not believe every spirit, but test the spirits to see whether they are from God, because many false prophets have gone out into the world.”