You went too hard, for too long, without enough training. Or it was too cold. Or both. If you have a good light there's no reason to worry about beating the dark.
20 rides of this distance is just a beginner. After riding all next summer it won't happen as easily. Take it easy. Keep your legs warm.