[ime-core] clear context first before delete lattice manager