I think he means how can he tell if that button was clicked versus lets say windows shutting down the program because windows itself is shutting down, or its shutting down because code told it to

there is code to determine if its closing because the X was clicked.. search the VB.NET forum for QueryUnload because that is the feature of VB6 that is not present in .NET, and I know this was asked before