You won’t get in a good enough workout in 40 minutes on the road (+10 min warm-up before and after the 40mins).
An hour on the turbo trainer is worth two on the road, there are lots of hour long drills you can do on the trainer, S.E’s, intervals, threshold work, all sorts ... and an hour is the right length for the trainer.
The only time I would do an hour training on the road is a recovery session the day after a massive effort.
Not all bodies react to the same training session, think about warming up 30 minutes first, and work out another 30 minutes, divide those remaining 30 valuable minutes in improving endurance, speed, and stamina. Pedal until you can´t breathe.
I have a nice hill about 1 km away. First section is about 9.1% gradient, 80 m altitude gain, and 880 m length. It takes 3 mins @ 400 W to do this section. Then 2-3 more mins to turn around, come back down, and get back to the start. Perfect for VO2max intervals and the whole workout can fit into an hour.
I'm doing this workout, or similar, twice a week at the moment. Seems to be working well.
I have a 3 mile loop with 5 short hills, one so steep I am standing at the end and about to fall over. Ride to it to warm up, then the loop the rest of the time plus the ride home. I can't wait to get this hip in shape so I can do that loop some more.