My question is: how can I stop committing this sin?.
The ways in which you can give up watching movies: you can achieve that by means of several things that were mentioned by the scholars and educators, such as the following:
1. Finding out about the shar‘i ruling, which has been discussed previously in many answers.
2. Bearing in mind that Allah, may He be exalted, is always watching and that He knows what is secret and is even more hidden. One of the early generation was asked about what they did that help them to lower their gaze and refrain from looking at haraam things. He said: By knowing that Allah sees you more quickly than you see what you are looking at.
3. Righteous friends who will remind you if you forget and alert you if you are heedless. They are close friends who love one another for the sake of Allah and you are brought together in obedience to Allah, may He be exalted. Allah says (interpretation of the meaning): “Friends on that Day will be foes one to another, save those who kept their duty (to Allah)” [al-Zukhruf 43:67]. That is the good companion whom the Prophet (blessings and peace of Allah be upon him) likened to the bearer of musk. It was narrated that Abu Moosa al-Ash‘ari (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “The likeness of a good companion and a bad companion is that of one who carries musk and one who works the bellows. With the carrier of musk, either he will give you some or you will buy some from him, or you will notice a good smell from him; as for the one who works the bellows, either he will burn your clothes or you will notice a bad smell from him.”
4. Keeping yourself busy with things will benefit you in religious and worldly terms. You should have a daily wird that you recite; memorize the Book of Allah; study some books by the scholars or listen to them, and busy yourself with things that are beneficial and serve the people and society.
5. Marriage, which is what the Prophet (blessings and peace of Allah be upon him) recommended to help lower their gaze and guard chastity, as he said: “O young men, whoever among you can afford it, let him get married, for it is more effective in lowering the gaze and guarding one’s chastity. And whoever cannot afford it, let him fast, for it will be a shield for him.” Narrated by al-Bukhaari (4779) and Muslim (1400).
6. Always asking Allah to help you, guide you and purify your hearing and sight. The best thing that a person can do to rid himself of evil inclinations after taking the proper measures is to turn to his Lord and ask Him to help him with that, to make things easy for him and to purify his physical faculties.
We ask Allah to enable you to do that which He loves and that pleases Him.
And Allah knows best.