Many people don’t realise that Basil is an annual. People complain that their Basil plant dies every year, well that’s what it does. The whole raison d’etre for annuals is to procreate, which means that they want to flower & produce seeds.To get a decent crop of leaves from your Basil, you need to diligently pick off the flower buds, these can be used just as well as the leaves for cooking or pesto etc. Keeping the plant from flowering encourages more leaf growth, if you let them flower, you end up with woody stalks & hardly any leaves, once the plant makes seeds, it dies off. It is possible to extend the life of Basil by growing it in the greenhouse or sunny window sill, but I think they lack the oomph of garden grown plants. If you make enough Pesto to last you a while , you can store it in a jar in the fridge, with a layer of olive oil on the top, or freeze it in small pots.