The rub is that if he resigns there's no guarantee he'll get an election.
The ad-hoc coalition that opposes a no-deal Brexit could form a government. Since some answers provide contrary opinion, here's a further quote from the Cabinet manual of what happens a government resigns without having a majority:
2.13 Where a range of different administrations
could potentially be formed, political
parties may wish to hold discussions to
establish who is best able to command
the confidence of the House of Commons
and should form the next government. The
Sovereign would not expect to become
involved in any negotiations, although there
are responsibilities on those involved in
the process to keep the Palace informed. [...]
2.17: The nature of the government formed will
be dependent on discussions between
political parties and any resulting
agreement. Where there is no overall
majority, there are essentially three broad
types of government that could be formed:
• single-party, minority government, where
the party may (although not necessarily) be
supported by a series of ad hoc agreements
based on common interests;
• formal inter-party agreement, for example
the Liberal–Labour pact from 1977 to 1978;
• formal coalition government, which generally
consists of ministers from more than one
political party, and typically commands a
majority in the House of Commons.
Even if this turns out to be a short-lived government, it could be enough to oversee an extension letter to the EU, which would certainly look bad enough for Johnson with respect to his "do or die" promise of leaving the EU by Oct 31. (And if this needs reminded, until BoJo took over recently, the Conservative party had sunk to the historically unprecedented 5th position in polls and less than 10% voter share at the EU recent election, largely for failure to deliver Brexit.)
On the flip side, it seems Johnson would have to break the Benn law if he doesn't ask for an extension himself if he stays as PM. So unless he finds a loophole to that law, he is indeed between a rock and a hard place with respect to his "do or die" promise...
Another option for him that is being discussed in the media is to stay on as PM and test the limits of laws/constitution by simply refusing to send the letter. There is talk of jail time and him becoming a "martyr".
As an additional point, there are two types of PM resignations contrasted in the Cabinet Manual (2.10):
- resignation from the "individual position as Prime Minister"
- PM resignation "on behalf of the government"
The former is supposed to happen while his/her party still commands a majority in Commons, and then the successor PM is chosen by the governing/majority party or coalition (2.18). The latter is supposed to happen when the party in government no longer commands a majority in Commons, and leads to a wider consultation process as quoted above (2.17).
Ultimately it is the Queen's responsibility, advised by the outgoing PM, to chose the "the person who appears most likely to be able to command the confidence of the House" (2.8-2.10). The Manual also says in 2.10 that the outgoing PM does not present his resignation to the Queen without being able to make a recommendation for a successor PM. That might be a reason why a PM would delay announcing his resignation in circumstances where the successor (and even the process for choosing one) is uncertain, although one also has to distinguish between a public announcement of the intention to resign, and [later] formally presenting the resignation to the Queen.
Finally, the OP comments below that a Corbyn government would (probably) be "even more chaotic" than the current situation, and so that the electorate would soon return BoJo triumphantly to power (somehow). My guess is BoJo himself is not so convinced it would play out this way. The OP assumes that the electorate will be very forgiving of BoJo in such circumstances, perhaps following a "people vs. Parliament" campaign, the specter of which some have compared to the Conservative stance in the 1914 political crisis. I think it's too chancy for me to comment on the likelihood of something like that succeeding as planned, especially if the Conservatives are not going to be the only game in town playing the hard-Brexit card. Insofar Johnson has not given Farage the unconditional promise of a hard Brexit that Farage demands for an alliance of sorts (a non-aggression pact, as Frage describes it.)