To start this tutorial, please first follow the 3rd of the series from http://technoracle.blogspot.ca/2012/05/third-neo4j-tutorial-getting-started.html
You' notice that on Neo4J's pages, they discuss a shutdown hook. So what exactly is that and why would anyone use it?
To add a shutdown hook to the code in the previous tutorial, navigate to the createDB() method and register a shutdownhook handler right under the line where you create the database. With the new line added, your code should look like this:
registerShutdownHook() is a static method that returns nothing (void). The syntax above is a bit confusing given line 91 calls addShutDownHook on a new thread and closes around line 99, hence the erroneous looking but much required "});" syntax. This essentially encapsulates the functionality. The shutdown hook ensures that the Neo4j instance shuts down nicely when the VM exits (even if you "Ctrl-C" the running instance before it has finished running. Try running this example now with the modifications and you should see the following print out in your console.