title: calling destructor to call a method before closing JAVA program
body: <p>I am writing a test with Selenium and JAVA, sometimes when I get an error I use <code>System.exit(1);</code> to close my test or in some other situations my test program is forced to finish, but I need to run a function in any case before shutting the program down, so Is there any destructor in Java that if I call my function there it will be called (guaranteed) if any thing forces my program to finish? </p>