A method and system for controlling patient recovery from anesthesia with an inhalation anesthesia agent are provided, wherein the patient during the recovery is ventilated with a ventilator, and the method comprises decreasing inhalation anesthesia agent concentration in the patient breathing gas to a level enabling patient spontaneous breathing, monitoring the expiration of the patient to determine at least the expiratory O2 concentration, determining a target level for the expiratory O2 level for the patient during recovery, comparing the determined expiratory O2 concentration with the target level for the expiratory O2 level for the patient, and controlling the O2 concentration in the ventilation gas to allow the expiratory O2 level for the patient to match the target level for the expiratory O2 concentration.