Store: rework file release in case of an error while opening. See #264