I have a C# application that consists of multiple forms, and there is no particular one which will always be closed last.
Where should I put a piece of code (i.e. dumping some information to a file) to ensure that no matter how the program exits, this happens just before the program closes?