fix: restore mode on error