The system should collect data over drive cycles before it throws a CEL. If you scan it you may see a "pending" code.

Same as when it turns it off. Once you fix the issue and drive it for x amount of time it will re-check everything and if it's all good the CEL will go out on it's own.