What is the best way to get rid of forbidden thoughts?
Or thinking about forbidden things. By Allah, I think the best way is not to sit alone.
Because it seems from this question that this only happens to him when he is alone.
Make sure not to be alone. Make sure not to be alone.
And if your room is empty, do not lock it.
Or leave the door open, train yourself like this.
So that you don't feel alone.
Then the shaytan isolates you. This is the best solution, of course, along with being mindful of Allah the Blessed and Exalted, and making du'a.
And thinking about his fate if he were to die in this state, how he would meet Allah the Blessed and Exalted, and other such matters. Allah is the One whose help is sought.