MOSFET 24V high-side switch
Q2 needs a 10 K pull-down resistor at the base to ground points. Left floating a transistor will not necessarily be 'OFF', so you make make sure transistor base (and gates) never float.
Also, R7 and R6 could be 10 times their value, reducing power consumed by Q2 when it is ON. The MOSFET input impedance is very high, many megohms, so no need to drive it with current. R7 should be less than R6. I would make R7 10 K and R6 47 K.
Diode D1 which is to suppress back EMF from a solenoid or other inductive load could be a faster BA157, but the 1N4xxx series is ok for slow switching speeds.
I copied and improved your schematic. This should work better.



simulate this circuit &ndash; Schematic created using CircuitLab