A brew is most at risk of spoilage when the yeast is not active. This may be at the start of the ferment (prior to or just after the yeast is pitched) or at the end of the ferment (when the yeast has sedimented to the bottom of the brew). A brew, fermented with the lid on or clingwrap, should have a protective layer of CO2 gas and may be perfectly fine for several days after fermentation is complete. However, the majority of brewers cannot produce a completely sterile environment for their brew so the longer the brew is left to sit the greater the risk of spoilage. Sample the brew prior to bottling - if it smells like beer and tastes like beer it is okay to bottle.