Added shutdown hook to close repository