if close(), set closed first