It's clearly determined at the start of the race. Once a race starts, if you click on another Torn page and hover your mouse over the racing icon, it will tell you exactly how long until your race ends.
[image: i.imgur.com]Since there isn't any way for us to interact with a race once it starts, that makes sense. It makes things a lot easier from a programming point of view to generate everything related to the race one time and be done with it. If we had some way to interact (where we're hitting a key to "accelerate" or hitting a key to "brake" or whatever) then the server would need to maintain a connection with every driver in the race the entire time. It wouldn't just need to talk to your computer to get your input and adjust the race, but also to tell your computer how the other drivers have done, where there cars are. Generating that all at once saves a lot of work.
That's also related to why you can continue to race if you get jailed, or hospitalized, because the race isn't being updated in real time.
And honestly, If we had to interact with the races, I'd race a lot less. Right now I'm in a 100 lap race. It'll take 5 hours. I guarantee I wouldn't sit at my computer, controlling my little race car, for 5 hours. The fact that I can start that race and then spend my time on other things encourages me to do it. I often do that when I am going to be asleep, or at work, and don't have time to do a lot of interaction with Torn.
Like Nitro said, Torn isn't a racing game.
And I think similar arguments can be made about everything in Torn. People that run a company don't have to control every aspect. People that work in jobs don't actually have to do anything other than log in once every day or two. Crimes take 2 or 3 clicks, then a digital dice roll is made, and you're told you succeeded or you failed. Thousands of people are busted out of jail every day, and little thought or effort goes into doing it. The number of warehouses built each day must be huge considering how many warehouses get burned down on a daily basis. Almost everyone has their own PI, which suggests that the Gulf of Mexico has thousands and thousands of beautiful tropical islands just off the cost of Torn City.
If you expect Torn to be realistic, you're going to be disappointed. It's not going to happen, because it's a game.