class Async::Scheduler

def close

@public Since `stable-v1`.
Terminate all child tasks and close the scheduler.
def close
	self.run_loop do
		until self.terminate
			self.run_once!
		end
	end
	
	Kernel.raise "Closing scheduler with blocked operations!" if @blocked > 0
ensure
	# We want `@selector = nil` to be a visible side effect from this point forward, specifically in `#interrupt` and `#unblock`. If the selector is closed, then we don't want to push any fibers to it.
	selector = @selector
	@selector = nil
	
	selector&.close
	
	consume
end