class Async::Container::Group

def stop(timeout = 1)

@parameter timeout [Boolean | Numeric | Nil] If specified, invoke a graceful shutdown using {#interrupt} first.
Stop all child processes using {#terminate}.
def stop(timeout = 1)
	Console.debug(self, "Stopping all processes...", timeout: timeout)
	# Use a default timeout if not specified:
	timeout = 1 if timeout == true
	
	if timeout
		start_time = Async::Clock.now
		
		self.interrupt
		
		while self.any?
			duration = Async::Clock.now - start_time
			remaining = timeout - duration
			
			if remaining >= 0
				self.wait_for_children(duration)
			else
				self.wait_for_children(0)
				break
			end
		end
	end
	
	# Terminate all children:
	self.terminate if any?
	
	# Wait for all children to exit:
	self.wait
end