Take the 2-minute tour ×  I have a bat script which runs a java
application. If I press ctrl+c on it, it the application
terminates gracefully, invoking all the shutdown hooks. However,
if I just close the cmd window of the bat script, the shutdown
hooks are never invoked.  Is there a way to solve this? Perhaps
there's a way to tell the bat script how to terminate the
invoked applications when its window is closed?  share|improve
this question add comment  3 Answers  up vote 10 down vote
accepted  From addShutdownHook documentation:  In rare
circumstances the virtual machine may abort, that is, stop
running without shutting down cleanly. This occurs when the
virtual machine is terminated externally, for example with the
SIGKILL signal on Unix or the TerminateProcess call on Microsoft
Windows.  So i think nothing to do here, unfortunately.  CTRL-
CLOSE signal in Windows Console. Seems non-tweakable.  Quoting
above link:  The system generates a CTRL+CLOSE signal when the
user closes a console. All processes atta