Why this happens at all
Desktop Notepad, the version built into Windows for decades, only writes to disk when you explicitly save. Until that happens, everything you have typed exists only in the program's memory, which the operating system reclaims the moment the process ends, whether that end is a normal close, a crash, or Windows shutting down unexpectedly. There is nothing malicious or unusual about this: it is how almost all traditional desktop software has worked since long before autosave was common, and it is the direct cause of the "did I just lose that" moment that sends people searching for a way back.
What Windows 11's Notepad added, and its limits
Recent versions of the built-in Notepad on Windows 11 introduced session restore: close Notepad with unsaved tabs open, and reopening it can bring those tabs back with their content intact, even without ever saving. It is a real improvement, but it depends on Notepad itself shutting down through a path the feature recognises, and it did not exist in Windows 10 or earlier builds at all. A full system crash, a forced power-off, or an older Windows version can all fall outside what it covers, which means it reduces the risk without removing it.
What you can try if it already happened
First, reopen Notepad rather than assuming the worst: if session restore is available on your version, the tab may simply reappear. If the program itself is frozen rather than closed, resist the instinct to force-quit immediately; Windows sometimes recovers an unresponsive window on its own after a short wait, and force-closing removes any chance of that. Beyond those two steps, there is no reliable general-purpose recovery for plain Notepad text that was never written to disk in some form, because there is no file for a recovery tool to search for. Undo history, temp folders and previous-versions backups occasionally help with other programs, but Notepad itself does not create the kind of recovery file that Word or Excel do.
The structural fix, not a recovery trick
The most reliable answer to "how do I recover unsaved text" is avoiding the situation where text is ever meaningfully unsaved in the first place. A browser-based notepad that writes to local storage on every keystroke, rather than waiting for an explicit save, removes the gap entirely: there is no moment where a crash or a closed tab costs you anything, because nothing was ever pending. The online notepad on this site works this way, saving to your browser as you type and reloading exactly where you left off, including after the tab or the browser itself has been closed.
Where that still has a limit
Browser storage solves the crash problem, not the durability problem. It lives in one browser on one device; clearing browsing data, switching browsers, or moving to a different computer all lose it the same way an unsaved desktop file would. For anything that genuinely cannot be lost, download it as a real .txt file the moment it matters, rather than treating browser storage as a permanent backup. It solves "I forgot to save," not "I need this in five years."