I have an app that will run for a variable amount of time and then...disappear.

Usually, when this application crashes (it does happen), I'll get a "Windows has encountered an error and needs to close..." window. I'm also catching issues in debug mode, but I also need to test in release.

Is there a way to intercept and log this disappearing act? I'm thinking of writing to a log file on this event when the app "disappears" but I haven't yet determined what function, exactly, I should look for.

Can someone shed some light on this problem?