I would keep going.
The arguments for stopping just don’t stack up. People say ‘he can do 25m, that’s enough to get him out of trouble/to the edge of a pool/boat’. It’s really not. That’s 25m in ideal conditions. If he is ever in trouble in the pool/ocean, he will likely be more exhausted already, there may be other children to save first or he will be having to swim and then tread water or vice versa. As someone said above, being able to swim 200m in ideal conditions, means you could be confident they could do 25m in an emergency.
’Butterfly isn’t an essential life skill’ - no, but now is algebra or languages, but it isn’t about that. All learning is about training your mind to think, and/or better handle other problems. In this case, learning other strokes has a benefit - butterfly uses so much more energy, if you can do 200m butterfly, you are fit enough to do far longer in the other strokes. Also backstroke is useful if you are in an emergency, you can swim freestyle and get exhausted, you can switch to backstroke for a short time and still make headway, but gain your breath back.
He gets discouraged - yes he will. And he will many other times in life. When he fails an exam, misses getting into a sports team/uni course, when a girl/boy he likes breaks up with him. Your role isn’t to protect him from the disappointment or discouragement, but to parent and give him the tools to get through it. Perhaps this is a good moment for later - in future he struggles with maths, you remind him how he struggled with swimming but he preserved and passed all the courses.
I say keep going. Remind him when he is 18 and wants to take a gap year to Australia, he’ll want to run into the ocean with his mates. He will not want to have to stay waist deep or return to shore (or be rescued by a lifeguard) as the strong waves there mean being able to swim for 25m is nothing.