The duration of a race varies according to the distance to be covered, the weather conditions, etc.
When the race is scheduled, it receives a theoretical end date. This date is displayed in the information window for the race in question. You can access that information by clicking the (i) button from the game home screen.
Once the indicated date is reached, the race is closed. You can still access it for a few days in order to check your performance and to claim the credits the game offers when buying your cards back, as well as the credits given to you based on your performance.