That's what Outlook's "Recall" feature does (at least outside your organization), but "Undo send" can be set to delay email sending and give you a chance to say "Wait I didn't mean to hit that" before it actually leaves your computer.
Well, it leaves your computer as soon as you type on the keyboard; that's how it saves drafts. The Undo feature works by telling Gmail servers to send the email in X seconds. That timeout gets canceled if you hit Undo. Or at least I assume that's how it works. I'm sure it doesn't wait to send data to the Gmail server until timeout is over. If that were the case, your email would never be sent if you closed the tab during the timeout.
Gmail's web interface also does this: https://support.google.com/mail/answer/2819488?co=GENIE.Plat...
In the top right, click Settings.
Next to "Undo Send," select a Send cancellation period of 5, 10, 20, or 30 seconds.