I have an issue with my application when Windows shuts down - my app isn\'t exiting nicely, resulting in the End Task window being displayed. How can I use the debugger to s
You could use the SystemEvents.SessionEnding event, which is fired when a user logs off or shuts down. Be careful when using it though, some resources are not guaranteed to be available. For example, my application needed to hit a server when it was shutting down to clock a user out (a timeclock application), but the network card is sometimes already disabled when this event occurs. Since you're just doing cleanup, this should work fine.