San Francisco was two outs away from seeing their division lead shrink to a half-game