Quick answer: Your game crashes when closing because something fails during teardown, the cleanup that runs as it exits: a shutdown-order problem where one system is destroyed while another still uses it, background threads not stopped cleanly, or a save-on-exit operation failing. It's easy to dismiss since the game was closing anyway, but it can corrupt a save written on exit, so it matters.
A crash when the player closes the game is easy to ignore, the game was quitting anyway, so who cares? But shutdown crashes matter: they can corrupt a save being written on exit, and they signal real lifecycle bugs. They happen during teardown, a phase that's frequently under-tested, so the cause is usually something about how the game cleans up.
Why Games Crash on Close
Shutdown runs a lot of cleanup quickly, and several things can go wrong. Shutdown order: systems torn down in an order where one is destroyed while another still references and uses it, causing a null/invalid access during teardown. Threads not stopped cleanly: background threads still running during shutdown touch state being destroyed, or aren't joined properly. And save-on-exit failures: many games save when closing, and if that save hits an error (a write failure, a serialization issue), it can crash, and leave a corrupted save.
These are lifecycle bugs that only manifest during the specific shutdown sequence, which is why they escape normal play testing, you don't 'play' the shutdown. A crash that always happens on close points at the teardown sequence; one tied to saving on exit points at the save path. The save-on-exit case is the dangerous one because it can destroy player data.
How to Diagnose It
Capture the crash and read the trace: a trace in cleanup/destructor code points at order or dangling-reference problems; a trace in thread code points at threads not stopped cleanly; a trace in save/serialization code points at the save-on-exit failing. The trace localizes which part of teardown is the problem.
Bugnet captures the stack trace and context with each crash and groups by signature, so close crashes cluster and you can see whether they share a cause (the same teardown step, the same save path) or correlate with anything (a platform, an action just before closing). Because shutdown crashes can be quietly common and quietly corrupting saves, having them captured rather than ignored is the first step to taking them seriously.
What to Do About It
Tear systems down in dependency order so nothing is used after it's destroyed, stop and join background threads cleanly before destroying the state they touch, and make any save-on-exit robust and atomic (write to a temp file and rename) so a failed save doesn't crash or corrupt data. The save-on-exit case deserves the most attention because a crash there can corrupt the save.
See our guide on fixing a game that crashes when closing for the steps. A clean shutdown protects both the player's final impression and, crucially, their save data.
A crash on close happens during teardown, shutdown order, threads, or a failing save-on-exit, and the last can corrupt saves. The trace shows which part of cleanup is failing.