He was close but could have pitted - but Max would have stayed out (with what remained a substantial risk that the race wouldn’t restart) and gotten the lead. So Mercedes thought it was best to keep the track position and bank on either the race finishing yellow or Lewis holding Max off, especially if the lapped cars weren’t allowed through before the restart (because usually that takes a lap and there weren’t enough laps left).
But race control ruined Mercedes’ calculation by sending the lapped cars between Max and Lewis around and ending the safety car on the same lap. So Max got to start just behind Lewis with new soft tires. Lewis was a sitting duck.