Bolting is when a plant switches into flower and seed mode. It's most obvious and prevalent in cool season, leafy plants. Lettuce and spinach grow very well when the days are cool and the nights are long. As soil temperature rises and the days grow longer, the plants stop putting energy into growing the sweet leaves and redirect it to flower production. Inevitably the flowers rest atop a coarse stalk and the leaves dry and shrivel.
If you recognize the change happening, you may be able to delay it slightly. You can pinch off the bolting flower shoots. With herbs like basil, the plant will put energy back into leaf production and the plant will get bushier. With leafy plants like lettuce you may get a few more days of harvest before the bitter taste is noticeable.
Changing the growing conditions can delay bolting. Mulch moderates the soil temperature and will delay bolting. Keeping the soil well watered will reduce soil temperature slightly. Growing cool season plants in areas that get partial shade or covering the bed with shade fabric can delay the inevitable too.
The better option, that is appropriate now, is to plant cool season plants in late summer. As the plants mature the days are getting shorter and the temperatures are getting cooler. The plant can't possibly bolt because the physical conditions of excessive heat and sun are waning. The plant will grow well, producing delicious leaves until you harvest it or a hard freeze in fall kills it.
For many, especially me, bolting isn't always a bad thing. It can be put to good use if you save seeds. The purpose of bolting is to produce them so I aid the natural cycle by letting it happen. The plant is happy because it has completed its life's journey and I'm happy because I have a bag of seeds to sow next year.
Much of my garden comes from continuing the cycle. Radish, rhubarb, cilantro, dill, and basil are plants I regularly grow exclusively from the seeds of previous generations. They are easy to collect, sow, and grow. I lose out on some of the harvest when the plants bolt, but I'm rewarded with an entire planting the next year. This summer I'll add spinach and lettuce to my list. I'm growing heirloom varieties and look forward to the same plants after next spring's sowing.
When you buy seeds of cool season plants you can look for ones that are "slow to bolt." If that is the case it will almost always be printed on the seed packet or in the catalog; it's a major selling point for many gardeners.
Bolting doesn't have to be the end of the garden when it happens. Put new plants in the bed, sow more seeds, get a second planting. Take the opportunity to extend your harvest well into fall. Many gardeners think with a one-season mindset, bolting allows you to break out of that model and get two seasons for little additional effort.