Method and system for controlling patient recovery from anesthesia with an inhalation agent, wherein the patient is ventilated with a ventilator during the recovery, the method comprising decreasing inhalation anesthesia agent concentration in the patient breathing gas to a level enabling patient spontaneous breathing monitoring the oxygen 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.