A JShell session has a variable `x` set from three lines ago, and it's still usable. Someone in the session calls `System.exit(0)` by accident to see what happens — and the JShell prompt is still there afterward, ready for the next line. What's actually happening under the hood that makes both of those true?
JShell isn't a separate, smaller Java — each line you type is compiled with the same Compiler API (javax.tools.JavaCompiler) that javac itself is built on, which is why a syntax mistake produces the same kind of compiler diagnostic a file would. Two things make it feel conversational rather than like a script that runs once and forgets everything: a variable you declare is kept as part of the session's persistent state rather than being a local variable that disappears when the line finishes, which is why x from three lines ago is still there — and, by default, your code doesn't even run inside the JShell process itself. JShell starts a separate JVM to execute what you type and talks to it over a local connection, specifically so that a System.exit(), a stack overflow, or anything else that would take a process down only takes down that separate JVM, not the session you're typing into.