Add graceful shutdown of tests