fix shelve bug that "with" cannot call close