Added shutdown hook to main method