You should use RoutingDimension::SetSoftSpanUpperBoundForVehicle(BoundCost bound_cost, int vehicle) which adds bound_cost.cost * (span - bound_cost.bound) to the cost if span > bound_cost.bound, where span is the dimension span on the route of the given vehicle. This allows to minimize extended working hours without enforcing route start or end times.
As mentioned by Laurent, you can also specify soft lower or upper bounds on specific cumul variables (for instance at the start or the end of the route) if you want to stay close to some specific start and end times for the route.