Depends on how long the individuals live. A species with a human-like lifespan (less than 100 years) would have to have fewer births than deaths for several generations before complete extinction. To be completely extinct in only two or three generations, they would either have to be rendered sterile practically all in one go or lose all of their females. A technologically advanced species would just clone themselves and implant the cloned embryos if any females were left, even if all the males were sterile. If you propose an advanced enough technology, they might not even need the females if they invented artificial wombs.
James Tiptree, Jr.(Actually a woman named Alice Sheldon writing under a male pseudonym in the 70's, an ex-CIA agent) wrote an amazing story about what might happen in a situation like that. It's in the story collection
"Her Smoke Rose Up Forever". It's called "Houston, Houston, Do you Read?" It's about a group of male astronauts who get pushed forward in time to a future Earth that's come up with a creative solution to a worldwide sterility plague. Very interesting story. The story of the author is even more interesting. She was a very talented writer, but one disturbed individual. Ended up killing herself in 1987. Most of her stuff is very feminist. You would think she was a man-hater, but she was married for many years to another SF author. She killed him before she suicided. He was bedbound and blind. She was in her 70's, he was 80 something. She shot him and then shot herself.