add a sanity check for closing