ERRORLEVEL is actually based on a very simple concept that almost all operating systems support. When a program terminates, it can pass an "exit code" value back to whatever invoked it (with DOS usually the command procssor but it could be another program).
In DOS, that exit value is a byte which means it can be anywhere from 0 to 255. Most OSs agree that 0 means "success" and non-zero means "something went wrong" an this value might help any calling program understand what.
Low values are mostly defined in DOS - I don't recall the exact values now, but things like "bad argument(s)", "file not found", "write error" etc. but higher values are "up tp the application" and not standardized. Which means you have to know what a particular value means from a specific application.
The DOS command processor mostly ignores exit codes, but at least when processing "batch" files it "remembers" the exit code from the last program run, and let you test it with "IF ERRORLEVEL ..." ... sadly it doesn't officially make this available in any other way which means you have no way to save it (other than 255 test/sets) or recall the exit code from a previously run program (at one point I wrote a little tool "ERRLVL {options} command ..." which has options to show exit code, save it to a file, write it to a spot in memory (of the calling program) etc.)
But... since DOS never made much "fuss" about exit codes, many early programmers (and dev tools) just exited without setting it. Fortunately this got better over the years.
PS: You could use my ERRLVL tool to figure out exactly what exit code are returned by a program (ie: game) when ended in various ways... I'm pretty sure it's on my site somewhere, if that sounds useful I can figure out exactly where and let you know.
- Dave ; https://dunfield.themindfactory.com ; "Daves Old Computers" ; SW dev addict best known:
ImageDisk: rd/wr ANY floppy PChardware can ; Micro-C: compiler for DOS+ManySmallCPU ; DDLINK: simple/small FileTrans(w/o netSW)via Lan/Lpt/Serial