Hot foods should be refrigerated as soon as possible after cooking (within two hours). Don't keep food if it's been out in the open for more than two hours. Don't taste it, either. Even a small amount of contaminated food can cause illness.
Date leftovers so they can be used within a safe time. Generally, they remain safe when refrigerated for three to five days. If in doubt, throw it out. The small amount of food usually involved is not worth a foodborne illness.