Ideal engine durations for gamma-ray-burst-jet launch