Some kind of thought will always come. As I said, true peace of mind, when our spirit reflects the peace of God is the achievement of a lifetime of prayer and fasting, not something that we conquer by sheer willpower.
These thoughts lay dormant in our "hidden files" of the mind, and are triggered, as you have experienced, by sounds, images, smells, situations, coming back to our conscious mind.
Each time they are triggered they are reinforced. And will return the next time with even less stymulus, and weaker, requiring a stronger stymulus to get the same impact. It acts basically like a drug.
Well, to get rid of them (the stage of purification), we must change the content of our "hidden files". This is a slow process. First, you must avoid everything that estimulates these thoughts (got now why some saints fled to the desert?). By this you will "starve" them to "death". At the same time, you can't simply keep the house empty or new bad thoughts will enter. You have to fill it with good things. Church recommendation is the lives of saints, truly healing images like those of the traditional icons, truly spiritually healing music like traditional religious chant (both byzantine or traditional gregorian). The forms of these stories, images and sounds will shape the form of your soul and heart. Of course, just like sins have those 5 stages, so does virtue. You can think of it and dialogue with virtue and that is not a virtue yet. You accept it is good and desire it, and you have a mental virtue. You practice it some times and this is practical virtue. When it becomes a second nature to you then you've been healed in that particular aspect. So you have the theoretical part where you let God purify your heart: you abstain of bad input, and search good input. then you reinforce the good things with practice until it becomes second nature. This process is Purification. When you are completely clean of all impurities, then you've reached Enlightment. After Enlightment you still have the final, holiest stage which is the fulness of the participation in the glory of God that is Theosis. And about that all is joy, peace and silence.
Some Fathers divided sin in 3, 5 or even more degrees.
Stage 01) Just a flash of an idea - that is still not a sin. The mind is always in movement, and only the most well trained ones have a real quiet or peace of mind. This is not a sin.
Stage 02) Dialogue with sin - Instead of simply not paying attention to the thought (no matter how long it is sustained in our minds), we start "talking" to it, sometimes improving it, sometimes simply keeping it there. This is still not a sin, but it is getting closer.
Stage 03) Mental Acceptance - It's that point where you think "You know what, this is quite good" and you cultivate and entertain the thought. You call it back sometimes and you rather like it. This is a mental sin.
Stage 04) Practice - You go and do it. Maybe once, maybe twice, but now it is not a thought anymore. This is a practical sin.
Stage 05) Passion or Addiction - Now you can't stop doing it, even if with long timed pauses. It's not any longer something you choose to do, but something that somehow has conquered you, it is something that you are made to do. This is slavery to sin.
Thank you, that's very helpful. What if the thoughts come back even if I don't want them to? For example if I come across something horrifying and get fixated on it? It's happened to me even doing something like flipping through the channels and glimpsing something especially graphic, or reading about something bad that happened in the news.