From Sahih Bukhari (Hadith 5208):
Narrated Jabir:We used to practice coitus interruptus while the Qur'an was being revealed. Jabir added: We used to practice coitus interruptus during the lifetime of Allah's Messenger (ﷺ) while the Qur'an was being Revealed
Reference: Bukhari 5208