Optimal resource depletion: Free end time problems