Can you choose how long you rest?
It seems that rest is by default 8 hours. I pull into the spot and pull out 8 hours later well-rested.
The issue, sometimes, is that waiting 8 hours is going to make your cargo late. I could rest for 4 hours, however, and still make the delivery on time. Is there a way to do this? Can I choose how long to rest or cancel the rest early?
Nope there is no option to take a nap. That is why it is important to plan your route ahead including any rest stops before hand. Especially for those 20 hour trips.
The only partial rest you can hope to get is if you get to ride the ferry on your route. This will rest you up for that amount of time. Other than that there is no other way.
Also if you are doing a free drive mission it less critical if you rest or not before taking up a delivery, but while driving your own truck it is crucial you start out missions with full rest and a full tank of fuel to be on the safer side. It might also make sense to rest early with a few hours remaining in your rest countdown as some routes are amazingly scarce on rest stops. You might hit these roads at exactly the wrong time and might be caught dozing off.