Use try / finally to clean up memory

Java does not play well with other memory managers