update: restore previous state when interrupted

Fixes #19460.
Closes #22375.