Add graceful shutdown check that assists in client cleanup