That is entirely dependent on how much you're leaving on the table by failing. When gambling, it might make sense to quit while you're up but that entirely depends on the expected value of your next bet.
From a macchiavellian perspective, you also have to consider how much benefit the founder would stand again from having a more successful startup instead of failing.