Fix reopen/close handling, for data consistency.