The purpose of a capacitor is to retain electric charge and it will do so even after its input voltage is removed. After the input voltage is removed, the capacitor will slowly discharge but, depending on the size and characteristics of the capacitor, discharging could take from a few minutes to a few years. So, it's never safe to touch a capacitor with your hands and you should make sure to discharge any capacitors in a circuit before working on it using an appropriately high-wattage resistor or a capacitor discharge tool.