Hi there,
The Zoom system doesn't actually count the number of participants in a meeting, but actually counts the number of joins to the session. This means that if someone disconnects, then rejoins, they are counted as 2 joins. It could be that you or the other participant disconnected, rejoined, and with the addition of the other participant, the 40-minute limit was likely triggered.
If you have any disconnects, its best to completely end the meeting so that the join counter is reset and you can restart the meeting without any issues.