The answer is to be sure that there is no longer any fermentation still happening. The only sure way to tell is to use a hydrometer or refractometer and take gravity readings. After all signs of fermentation have stopped wait a couple more days then take a gravity reading. Wait 2 more days and take another reading. If the numbers are the same it is safe to bottle. If you have not reached final gravity and bottle the beer, further fermentation (co2 production) could raise the pressure in the bottles until they explode.
Depending on the temperature of the fermentation, colder = longer, I have seen fermentations take about 10 days. Do not rely on time alone.
Many, myself included feel the yeast will continue working cleaning up off flavors that are created in the process of fermentation. How long this takes is up for debate. Some feel it is done in a day or two after reaching final gravity. Others say 4 or more weeks. I opt for fermenting in primary only for 2-3 weeks then check gravity and package.