Back emf: from the coil of the contactor/relay.

But I don’t know the particular UB1 output spec. If a mosfet might find it has a commutatinf diode built in, otherwise place a 1N4001 across the coil, cathode to 24v line, anode to ground