Heat oven to 400°F and arrange rack in the middle. Meanwhile, heat oil in a large, high-sided frying pan over medium-high heat. Add onions, garlic, carrots, and celery and season with salt and pepper. Cook, stirring occasionally, until tender, about 5 minutes.
Sprinkle flour over vegetables and cook, stirring constantly, a few minutes to allow flour to get slightly toasted. Add madiera and stir, scraping up any browned bits on the bottom of the pan. Add chicken, broth, potato, measured salt and pepper and thyme and bring to a boil.
Reduce heat to low and simmer until potatoes are just beginning to become tender on the outside and broth has thickened slightly, about 15 minutes. Add peas and parsley and stir to incorporate. Taste and add more salt and pepper if necessary.
Transfer mixture to a 9-x-13-inch baking dish and let cool while you roll out the dough.On a lightly floured surface, roll out the dough into a 10-x-14-inch rectangle and place over filling. Fold edges over themselves and create a decorative edge by pinching the dough together at intervals around the exterior.
Cut 8 or 9 slits into the top to vent the steam. Add a tablespoon of water to the beaten egg and brush egg wash over the top (see picture above).
Place in oven and bake until crust in golden brown and mixture is bubbling, about 45 minutes. Let sit 10 minutes before serving.