Look at the schematic diagram of a circuit below, imagine if the capacitor C1 is not charged and the power is off. There will be no current flow and Q3 will be open. The Base of Q3 will be high and the Base of Q2 low. The circuit is in stable condition and nothing happening. Power will flow through the diode and to the base of Q2 if we press SW1. Q2 will conduct so the base of Q3 will go low and the transistor Q3 will conduct and current go through this transistor and keep feeding the transistor Q2. Then the circuit is unable to deliver power to the output.
Capacitor C1 will start to charge through resistor R1 at the same time you press the SW1 button. The transistor Q1 will start to conduct and pull down the current through the base of Q2 if the voltage is higher than 0.7V. This mean the Q3 will not be conducting and the circuit is shut down when you let SW1 button go off.
The value of R1 and C1 determine the time before the circuit on and off. You need to experiment yourself. It’s depends on which transistors you are using and you can use any kind of transistor. Just make sure that transistor Q3 can handle the current that you are going to draw through it. [Circuit’s schematic diagram source: Smart Switch]