Added shutdown hook and on-close success reporting to main program