First place is to think about what an inductor (the solenoid) does: It opposes any change of current, by doing whatever is necessary to keep the current flowing, at the same A, and in the same direction. In the circuits below, as the switch opens, the voltage will go up, above V+, until current is forced to flow (through the absorber component or by sparking or by breaking down the switch transistor).
Second is that an inductor has a fixed amount of energy stored in it (1/2 L.I^2) which is available to power the flyback. (or heat up the zener)
So the flyback current is never greater than the on current of the solenoid. (3.1W/24V = 130mA)
The flyback current will flow until the energy is dissipated as heat in the diode/zener/inductor-R. Initial current is fixed at Ion, so the power dissipated in the diode is much greater at a zener voltage of 30V that at a diode voltage of 1V : therefore the energy is dissipated much faster, and the current stops much quicker.
simulate this circuit – Schematic created using CircuitLab
So L1 has a simple diode, and the current will keep flowing for max time as Vdiode is 1V.
L2 has diode+Zener. This is nice because the zener can have any voltage you want at all - the supply voltage is never across the zener. So you could say: I have a 1.3W zener, 130mA maximum will flow, so I will use a 10V zener and never ever overheat it. Or a 400mW 3.3V zener. Even with a 3.3V zener it will still be 4x faster than a diode. (The drawback - an extra D2)
L2b is using a resistor instead of the zener. The value must be matched to the on current of the specific solenoid. (from @OlinLathrop)
L3 Just use a zener. But the zener V has to be greater than the maximum possible V+, including all tolerances. So perhaps it is a 39V zener. Peak power will be 39Vx0.13A = 5W. Probably OK for a 1.3W zener as it is momentary, but you really need to watch the total pulse energy carefully. Probably bad for a 400mW zener.
L4 dissipates the energy in M4 by turning D5 must still be 39V. This approach works as the inductor energy gets bigger.
If the circuit was perfect the voltage across the switch would instantly rise from 0V to Vclamp (25-60V), generating an RF pulse of EMI, in your case of a solenoid, with nice long antenna wires. In practice the rise time is set by the various parasitic capacitances across the coil,diode,switch etc. However it is often desirable to design so that the switch is slowed, and reduce the rise time. R1+gate capacitance of M1 slows the switching down. (It also protects your micro when M1 fails by drain-gate punchthrough)