The ON/ON switch is required to connect to V+ or to GND. When connected to GND, the capacitor discharges much faster. When connected to V+, the capacitor charges in a gradual manner due to the connection of R1. Instantaneous discharge of capacitor C1 can be done under connecting switching diode between C1 and SW1 thus bypassing R1. To prevent reflections and voltage spikes, a resistor R2 is placed at the input.
The values of R1, R2 and C1 are approximate and depend on the application.
Zener diode D1 is better than a voltage divider with two resistors because the voltage spikes can be much higher than the supply voltage. A zener will always give a predictable voltage, whereas a voltage divider will only divide the given voltage and it may be higher than expected. Of course, you can replace the zenner diode with a resistor if you wish, or double the zenner diode with a resistor in case the switch is floating or if you cannot place an ON/ON switch. If you can’t use such a switch, then you need to think about reducing the impedance of the resistor to ground. Or something else. But then it will draw a little more current because the supply is 24V.
The voltage spikes can be higher than the supply voltage by using a D1 zener diode. This is a better application than using a voltage divider with two resistors. The zener diode always provides a voltage that can be predicted. A voltage divider, on the other hand, only divides the set voltage and can often exceed the expected values. If it is not possible to place an ON/ON switch or the switch is to be floating then you can replace the zener diode with a resistor or use a doubled zener diode with a resistor. Reducing the resistor impedance to ground is required if an ON/ON switch is not possible. It is also associated with an increase in current draw when powered by 24V.
The next diagram shows the solution when a momentary switch is used without using an ON/ON switch. C1 is filled with the divided voltage and the zener diode limits the voltage that is supplied to the base of transistor Q1. The discharge time with C1 1uF R2 10K is 40 times shorter than with 20uF and 20K.