First post, by etil
If the user closes the console window pressing ctrl-break or clicking the 'X' on the upper right corner dosbox crashes: dosbox.exe caused an Access Violation at location 6813fe30 in module SDL.dll Reading from location 127cf100. But dosbox exits normally when the console is closed pressing ctrl-c.
Sdl sets handlers for SIGINT and SIGTERM signals. The handlers push an SDL_QuitEvent in the event queue and the application can normally exit. When the user presses ctrl-c the run-time generates SIGINT signal and dosbox exits without crash. But signals are not generated if other events occur (ctrl-break, clicking the 'X', logging off, shutting down) and the default event handler causes dosbox to crash. I don't know the reason of the crash. I guess dosbox is terminated without calling SDL_Quit().
An application should install an handler function with the SetConsoleCtrlHandler winapi function and can handle the console events. Or sets handler for SIGBREAK signal and the run-time generates SIGBREAK when an console event occurs (excepting ctrl-c).
I have attached a small patch. It should avoid crashing.