Yes,one option would be set specific time in hours - race is over when time is up and the leader crosses the finish line.
Other option - calculate. For example you want the race last about 1 hour long and you have for example a track/car combo with laptime 1min30. Convert the hour (3600s) and laptime (90s) in seconds and divide it like this:
3600/90=40
This means 40 laps of racing will be about 1 hour long.