Added shutdown hook to terminate tests gracefully