#if Java
public static void addShutdownHook() {
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
ba.raiseEventFromDifferentThread(null, null, 0, "shutdown_hook", true, null);
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
}
#End If