Every now and again, I come back to my laptop and find that it has rebooted for some reason, while I wasn't expecting it. A prime cause of that is Windows Updates. I really, really wish that wasn't so, but someone at Microsoft has decided that I must apply these updates. I have very little control over the time when that occurs. For example, if I'm on the road delivering presentations, there's no "wait till I get home" option for Windows Updates.
Either way, it's really helpful that SQL Server Management Studio (SSMS) now creates periodic backups of unsaved queries.
You can control how often it does this, and how long it keeps the files for by adjusting the values in Tools, Options here:
If SSMS crashes, you'll be prompted to recover the unsaved files when it restarts. But if you want to just go and find these files after another type of shutdown that you weren't planning on, you'll find them in your Documents folder in Windows, under the subfolders, SQL Server Management Studio, then Backup Files, then the name of a solution (likely Solution1 if you didn't create a scripts project).