Depends on the mare and how she's handling the pregnancy, her comfort level, etc... I normally quit around 6 months.
I've heard stories of people buying mares and they think they're just chunky, but they're really pregnant. Said mare is at a show and when the riders/owners show up in the morning to feed there is a foal in the stall. At first it's like a "who's playing a joke on me?" then it turns into "my horse just foaled... let me go scratch today's classes!" I can imagine that's a fun one to explain to the secretary! The mares obviously showed no signs of being about to foal...
In the beginning it shouldn't matter much. I'm not 100% on what the verdict is of mares potentially slipping a foal in hard work at the beginning, but fairly normal exercise for typically the first half of the pregnancy is alright. Once she starts getting bigger, she's obviously dealing with a lot more strain and you should adjust your rides accordingly. But yes, mares can be ridden lightly right up to pregnancy. In fact, it's highly advised to keep them in work as a fit and conditioned mare foals 10x easier then a mare who's been allowed to go soft and fat.