The wording avoids the act itself
It does not forbid the thing. It forbids getting close to it.
وَلَا تَقْرَبُوا۟ ٱلزِّنَىٰٓ ۖ إِنَّهُۥ كَانَ فَـٰحِشَةً وَسَآءَ سَبِيلًا
Wa lā taqrabu-z-zinā, innahu kāna fāḥishatan wa sā'a sabīlā.
“And do not approach unlawful sexual intercourse.1 Indeed, it is ever an immorality and is evil as a way.”
The prohibition is placed at the approach, not the act, which is where it is still possible to stop.
Source
The Qur'an · 17:32
Qur'an
- Qur'anic text in the Uthmani script via Quran.com; translation: Saheeh International