SYC has good points. A monostable flip flop set for 40 seconds would be suitable for use in a toy. The 40 second accuracy would be subject to power supply voltage, capacitor tolerance, capacitor temperature drift, capacitor aging, capacitor current leakage, electrical noise etc, etc..
If you need high accuracy, use a stable oscillator and countdown circuits.