The Family Of Imran - 3:135
Those who, when they commit a sin or wrong themselves, remember Allah and ask forgiveness for their sins. Who can forgive sins except Allah? And they do not go on sinning knowingly.
The righteous remember God when they sin:
The Stories/28:16
"My Lord,"he said, "I have wronged myself, forgive me."And He forgave him. For He is Forgiving, Merciful."
The Stories/28:15
"He entered the city while his people were unaware. He saw two men fighting there, one from his side (Hebrew) and the other from the enemy´s side (Egyptian). The man from his side asked him for help against his enemy. So Moses struck the other with a blow and finished him off. He said, "This is the work of Satan; he is an enemy, a clear misleader."
The Heights/7:201
Whenever a dark suggestion from the devil reaches the righteous, they immediately remember. So they immediately see.
Prophet Hud/11:47
"He said: "My Lord, I seek refuge in You for supplicating to You about a matter of which I have no knowledge. If You do not forgive me and have mercy on me, I shall be of the losers."
The Heights/7:149
"When they regretted what they had done and realized that they had gone astray, they said: "If our Lord does not pity us and forgive us, we shall be losers"."