In the first place, we would like to stress that the Prophet (peace and blessings be upon him) is reported to have said, “When the month of Ramadan comes, the gates of Paradise are opened and the gates of the Hellfire are closed, and the devils are chained.” (Reported by Al-Bukhari)
It is clear from the above hadith that devils are chained during the month of Ramadan, but the reality tells that there are some people who sin and violate the sanctity of the blessed month. However, there is no contradictions between the above hadith and this reality according to many commentators of hadith, what is meant is that Satan has no control over those people who are righteous and obedient to Allah’s Ordinances. There is a clear reference to that in the Qur’an as Allah Almighty says while referring to the fact that one should seek Allah’s Refuge from the accursed Satan says, ” And when you recites the Quran, seek refuge in Allah from Satan the outcast. Lo! he has no power over those who believe and put trust in their Lord. His power is only over those who make a friend of him, and those who ascribe partners unto Him (Allah).” (An-Nahl 16: 98-100)
Thus, the accursed Satan has no influence over the committed believers. His influence extends only to those who expose themselves to sin and violate Allah’s rules in this blessed month. As a result, it is no wonder that their religious immunity is weakened by the Satanic penetration. Thus, they themselves provided the helping tool for the accursed Satan to weaken their immunity.
Furthermore, Ramadan is a perfect environment for religious commitment and spiritual purity, but this very special environment maybe exposed to sinful pollution as a result of reckless members who has no sense of appreciation to the sanctity of the blessed month.
Let us all consider the holiness of this blessed month and contemplate time and again over the Prophet’s hadith in which he used to say the following words when the month of Sha`ban draws to a close: “O Muslims! A noble and generous month has come to you. A month in which a night is better than one thousand months, and this month is the month of charity, patience, and mercy. In this month the gates of Paradise become  opened and the gates of Hell are shut, and the devils are chained…” (Reported by An-Nasa’i)

With this in mind, we do stress that not all the bad inner thoughts you have render you into an evil person. According to Sheikh Ahmad Kutty:

“Our thoughts can be divided into different categories:

1) the constant self-talk or idle thoughts that assail our minds and over which we have no control

2) Thoughts that we dwell on

3) Intentions that we formulate based on those thoughts.

We are not accountable for the first stage, namely the self-talk, since we have no control over it, unless we dwell on the thoughts and nurture them in our minds. We are accountable if we dwell on them. We are also accountable for the deliberate intentions that we formulate based on these thoughts.”

Hence, try your best to rid yourself of whatever bad thoughts you may have and make your intention pure to honestly submit yourself to the Well of Allah in the remaining days of this blessed month of Ramadan.