<p>I have a Java application which I want to shutdown 'nicely' when the user selects Start->Shutdown. I've tried using JVM shutdown listeners via Runtime.addShutdownHook(...) but this doesn't work as I can't use any UI elements from it.</p>

<p>I've also tried using the exit handler on my main application UI window but it has no way to pause or halt shutdown as far as I can tell. How can I handle shutdown nicely?</p>

[{'answer_id': 61697, 'author': 'Mladen Janković', 'author_id': 6300, 'author_profile': 'https://Stackoverflow.com/users/6300', 'pm_score': 4, 'selected': True, 'text': '<p>You can make shortcut to:</p>\n\n<pre><code>msiexec /uninstall [path to msi or product code]\n</code></pre>\n'}, {'answer_id': 5278703, 'author': 'Jan Hettich', 'author_id': 315595, 'author_profile': 'https://Stackoverflow.com/users/315595', 'pm_score': 1, 'selected': False, 'text': '<p>Setup Projects have a "RemovePreviousVersons" feature that covers perhaps the most compelling use case for uninstall, but it keys off the "Product Code".  See <a href="http://msdn.microsoft.com/en-us/library/y63fxdw6.aspx" rel="nofollow">MSDN documentation</a>. This "Product Code" doesn\'t seem to have been very well named, as it needs to be changed every time you update the Version number.  In fact, VS2010 prompts you to do so.  Unfortunately, neither the Product Code nor the Version number appears in the file properties of the generated .msi file.</p>\n\n<p>This solution suffers from similar limitations with respect to maintainability as the  prior suggestion that includes this same inscrutable Product Code in a hard-coded shortcut.</p>\n\n<p>In reality, there don\'t seem to be any very attractive options here. </p>\n'}, {'answer_id': 36390790, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>Visual Studio 2013 allows you to create an Uninstall shortcut in the shortcut design page if you use the Installshield Add-on.</p>\n'}]
['https://Stackoverflow.com/questions/61692', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1849/']