Putting display to sleep with AirPlay crashs apps in macOS High Sierra
I have had the same issue, but it got fixed after upgrading to macOS High Sierra 10.13.4.

I use AirPlay daily at work to connect to AirServer running on a Windows PC that has an external monitor attached, so that I can have a second external monitor on my MacBook Air. And when I walk away from my desk, I either Lock Screen with the Command + Option + Eject shortcut or using hot corner to put the display to sleep with password protection. When I would come back, I would have to login again and all apps were restarted. No kernel panic, but the OS itself appears to crash.

I discovered that the WindowServer itself that was crashing. Opening Console.app, and looking under "System Reports" in the sidebar, I found crash reports for WindowServer at the exact times that I had locked my Mac. I sent the crash report to Apple yesterday via their feedback form, but then I also decided to upgrade to 10.13.4 to see if there's any chance the problem had been fixed already, even though there was no mention of it in the release notes.

And after a bunch of testing today, it looks like the problem has been resolved. I've now connected to AirPlay as usual, and locked my screen multiple times both with the Command + Option + Eject shortcut and using a hot corner to put the display to sleep, and in both cases, the Mac was able to wake up, and I could log back into my running system, with all the apps still running, as expected.

Weirdly, I'm experiencing different behaviour now depending on whether I lock via the keyboard shortcut or via the hot corner:

Keyboard shortcut: Disconnects from AirPlay display altogether. On wakeup, Mac will auto-unlock via the Apple Watch, although it takes a bit longer. I have to reconnect to AirPlay display.

Hot Corner: Doesn't disconnect from AirPlay (at least not immediately, it just shows a black screen). On wakeup, I'm presented with the login screen asking for my password, but the Mac does not auto-unlock via the Apple Watch. I don't however have to reconnect the AirPlay display.

I'll send the feedback for the aforementioned issues but the crashing appears to have gone.