Return to depot not respecting latestArrival of vehicle


I have a requirement wherein vehicle needs to work in a shift (consider 9 to 7). Also, it is expected that the vehicle should return to depot within this shift time. Currently, I have achieved the shift times by defining the earliestStart and latestArrival of the vehicle and switching on return to depot property of the vehicle. But, it seems only the services are getting fulfilled within the shift time and return to depo time is not getting considered within this shift.
eg. Shift Time- 9-7
Last service end time - 6:30
Return to depot time - 45 mins
Route end time: 7:15

Expected behaviour: The last order should remain unassigned and route end time should be before 7

How can I achieve this?

Ideally vehicle should return to depot before latest arrival time. Can you share your implementation of code so that I can have a look?