Preheat the oven to 400 degrees Fahrenheit. Melt the butter in a large skillet over medium heat.
Add the sliced leeks and cook for 3 minutes until they soften. Stir in the mushrooms and cook for 6 minutes more until they release their liquid and begin to brown.
Add the minced garlic and cook for 1 minute. Sprinkle the flour over the vegetables and stir for 2 minutes to form a light roux.
Slowly pour in the vegetable broth while stirring, then add the heavy cream, dried thyme, salt, and black pepper. Simmer for 5 minutes until the mixture thickens.
Transfer the filling to a 9-inch pie dish or four individual ramekins. Roll out the puff pastry and lay it over the top, trimming any excess. Cut a few small vents in the center.
Brush the pastry with the beaten egg. Bake for 20 to 25 minutes until the crust turns golden brown and the filling bubbles at the edges.