Was hat der eine Code mit dem anderen zu tun
?
Der Snippet-Code zeigt einen Sicherheitsdialog an, um das Schließen eines Fensters vom User bestätigen zu lassen, und dein Code schließt alle Fenster und schlussendlich die Anwendung; das sind doch zwei Paar Schuhe.
Dein Code mit Application.Exit() ist soweit richtig[meta]Jedenfalls unter .Net 2.0, siehe SDK[/meta], den Dispose()-Aufruf solltest du aber entfernen. Ob du nun deinen Fenstern noch diese Sicherheitsabfrage hinzufügst, ist deine Entscheidung und hängt vom Typ der Anwendung ab.