This problem is easiest to explain just the way I explained it. The course is measured by observers at rest to the course. It is 4 million miles long. You are moving at 1/4 million mph as measured by the observers at rest, so you take 16 hours to complete the course. What could be simpler?

Now you, inside the spaceship, are moving during the race, so your time is dilated. You take less time to complete the course than the observers at rest will observe. When you exit the spaceship, your watch is behind the obervers'.

During the race, you see the length of the course shortened by the Lorentz length contraction. This has to coincide with the time dilation, because you are going to finish sooner than the observers at rest measure. In fact, the time dilation formula in SR is derived from the Lorentz length contraction formula, so they are different ways of saying the same thing.