As the south pole of the loop electromagnet comes closest to the permanent magnet, the paint turns off the electric current.
(the south pole of the loop electromagnet; comes closest; )
the south pole of the loop electromagnet
comes closest