title: Close all open WinForms but one?
body: <p>I am working with a windows forms application, .NET 3.5. I have set a timer such that if there is no activity after a certain period the current form is closed and the user is returned to a default "not logged in" form, which displays certain information but does not allow access to other forms. </p>
  
  <p>Application.OpenForms gives me a list which allows me to close most forms that might be left open, but Application.OpenForms seems to be aware of only the MDI forms. Some of these MDI forms may have MessageBoxes or other modal forms. There may even be cases where the modal forms themselves have popup dialogs. </p>
  
  <p>I am aware of the quirk <a href="https://stackoverflow.com/questions/3751554/application-openforms-count-0-always/3751748#3751748">(bug) in Application.OpenForms</a>, I don't believe there are any cases where properties are being altered after a Messagebox or other similar form has been created. In any case, that should effect only those forms, all others should still be listed in ApplicationOpenForms.</p>
  
  <p>Is there an elegant way to iterate through and close every form of whatever type in the application except the one I care about? (Or strictly, to close them all but the MDI Parent then open the one I care about.)</p>