class Async::Scheduler

def close

@public Since `stable-v1`.
def close
	# This is a critical step. Because tasks could be stored as instance variables, and since the reactor is (probably) going out of scope, we need to ensure they are stopped. Otherwise, the tasks will belong to a reactor that will never run again and are not stopped.
	self.terminate
	
	Kernel::raise "Closing scheduler with blocked operations!" if @blocked > 0
	
	# We depend on GVL for consistency:
	# @guard.synchronize do
	
	@selector&.close
	@selector = nil
	
	# end
	
	consume
end