As far as I know, in Java there is no way to catch system shutdown or logout events.
You can, however, catch when the JVM completes by adding closure to completion .
AWT WindowAdapter windowClosing, , . ; , SWT . , , !
, MS Windows . , SIGTERM Linux/UNIX , Linux SIGKILL , .