  Recently, a kilonova-associated gamma-ray burst (GRB 211211A), whose light
curve consists of a precursor ($\sim$0.2 s), a hard spiky emission ($\sim$10
s), and a soft long extended emission ($\sim$40 s), has attracted great
attention. Kilonova association could prove its merger origin, while the
detection of the precursor can be used to infer at least one highly magnetized
neutron star (NS) being involved in the merger. In this case, a strong magnetic
flux $\Phi$ is expected to surround the central engine of GRB 211211A. Here we
suggest that when $\Phi$ is large enough, the accretion flow could be halted
far from the innermost stable radius, which will significantly prolong the
lifetime of the accretion process, and so the GRB duration. For example, we
show that as long as the central black hole (BH) is surrounded by a strong
magnetic flux $\Phi\sim 10^{29}\rm cm^{2}G$, an accretion flow with
$\dot{M}_{\rm ini} \simeq 0.1 M_\odot s^{-1}$ could be halted at 40 times the
gravitational radius and be slowly transferred into the black hole on the order
of $\sim$10 s, which naturally explains the duration of hard spiky emission.
After most of the disk mass has been accreted onto the BH, the inflow rate will
be reduced, so a long and soft extended emission is expected when a new balance
between the magnetic field and the accretion current is reconstructed at a
larger radius. Our results further support that the special behavior of GRB
211211A is mainly due to the strong magnetic field of its progenitor stars.
