Did you still have your base left? You could still churn out units?
This is a legitimate strategy. Sucks to be on the receiving end, but comebacks are possible if there has been a base trade. If there has not been a base trade and he gets you to gg out, then he won, plain and simple.
Next time you get a game like this where you have obviously won, but it is getting dragged out, just grind him into the ground. Take an expansion, macro up and cover the map in your units. Eventually you'll find all of his bases and drones and you can finish him off. If you can still produce units at a decent rate, he'll never catch up, you just gotta keep on going. The mistake that is easy to make is to think that you have more units so you just go search and destroy and forget about replacing units while you are doing this.
Fullstop and Maynarde give some good advice. Take what you can learn from this match and use it to play better next time, but do not beat yourself up too much. Everyone has a game like this at some point. It is up to you to make sure it does not happen again.
Even the smallest donations help keep sc2sea running! All donations go towards helping our site run including our monthly server hosting fees and sc2sea sponsored community tournaments we host. Find out more here.