Anything can spoil eventually, refrigerated or not. Keeping something under a lid and refrigerated restricts the number of airborne colonizers that might get access to it, and the cold temperature means that even if they get there, they will grow much slower than at room temperature.
For something to spoil, it needs to be colonized by bacteria or fungus spores, and it needs to contain some nourishment to support their growth, not too much chemicals that prevent their growth, and not too much competing life forms already present. So, things with a high concentration of salt or sugar tend to be unhospitable to bacteria and fungi growth, because they are hygroscopic (they draw the water out of cells). Extreme high or low pH (eg acidic) also retards growth. Think of things like ketchup, mustard, jelly with labels that say "refrigerate after opening" but most people ignore them. Alcohol is unfriendly if the concentration is too high, and of course natural fermented foods are already occupied by human-friendly bacteria.
Ketchup is sealed in a bottle, usually with no fingers or utensils inserted into it, so it stays pretty sterile. It is also protected by being hygroscopic (due to high concentration of sugar and salt) and its acidity. Ketchup as a word and concept is descended from an Indonesian fish sauce, and has been around much longer than refrigeration. I think you can leave it out with no worries unless you see obvious mold growth.