Certified GKH Gardening Expert
You can't really stop it from going to seed. It's a biennial, and goes to seed as a means of repopulating. Once the seeds have been shed, it will die. You MAY be able to prolong it by removing the seed stem. Harvest leaves for cooking from first-year plants only and allow at least one or two second-year plants to fulfill their flowering/seed producing cycles to replenish your garden.
Here is an article that you may find helpful: https://www.gardeningknowhow.com/edible/herbs/parsley/tips-on-how-to-grow-parsley.htm