You can sorta do it w/ the Runtime method, addShutdownHook. This will be called whether it's exited normally or w/ Ctr-C though, so you may want to add some way to check.
Code:
import java.lang.System;
import java.lang.Runtime;
public class A {
public static void main(String args[]) {
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
System.out.println("Exited!");
}
});
for(;;);
}
}
Compile, then run this, and type Ctr-C while it's running. It will print
Exited! to the terminal... at least it should