Using capacitor to maintain current flow past opening of switch
Don't use 2N2222, use 2N7000 MOSFETs (that motor must be small) and it will be much easier. Try this:



You will have to tweak the value of R5 to fine tune the timing. D2 is there to avoid C1 discharging through anything that isn't R5, and to charge C1 as fast as possible. The time constant between R5 and C1 determines the turn-off time.

This circuit could be improved by doing a harder switching action on M1 to lower switching losses, but if it is not switched on-off very frequently, it will work fine.

Oh, and dont forget about the flywheel diode D3, the motor inductive spike can be very nasty.