One always strives to write exception safe application but there are times when an exception can go unhandled.
In the .NET Framework, the AppDomain class exposes the UnhandledException event that can be used by by the managed application to know when an exception has gone unhandled. In the writeup, AppDomains and Unhandled Exception Notifications, I discuss the specifics of when and how this notification is made, what is the relationship between the thread that had unhandled exception and the AppDomain(s) for which this notification will be done and what should be done during the notification callback.
The source code for the article can be downloaded from here.