Continue eating them as usual but stop breeding new ones. Most of them only live a few months, they'll all be gone within two years.
The species won't go extinct either, we can still keep some around in their natural habitats and zoos, which are both much nicer conditions than most farms. Preferably we won't keep around the breeds that were created for farming, they just aren't healthy animals.
The next quandaries are what do farm owners, farm workers, slaughterhouses, tanners, textiles, feed companies, agriculture focused veterinarian services and products, etc, do now that they're no longer needed?
The species won't go extinct either, we can still keep some around in their natural habitats and zoos, which are both much nicer conditions than most farms. Preferably we won't keep around the breeds that were created for farming, they just aren't healthy animals.