fix magic_close bug