Preheat the oven to 400°F (200°C). Lightly grease six 6-ounce ramekins.
Roll out the thawed puff pastry on a floured surface to about 1/8 inch thickness and cut into rounds slightly larger than the ramekins.
Melt butter in a large skillet over medium heat and cook the chopped onions until translucent, about 4 minutes.
Add garlic and sliced mushrooms to the skillet and cook, stirring occasionally, until golden and moisture has evaporated, about 8-10 minutes.
Stir in fresh thyme leaves and flour; cook another 2 minutes to eliminate raw flour taste.
Gradually add vegetable broth while stirring continuously and bring to a simmer.
Add heavy cream and reduce heat; cook until the sauce thickens, about 5 minutes.
Season the mushroom mixture with salt and freshly ground black pepper to taste.
Divide the filling evenly into prepared ramekins and sprinkle shredded Gruyère cheese over the top.
Cover each ramekin with a puff pastry round, seal edges gently, and brush the tops with beaten egg.
Place ramekins on a baking sheet and bake for 15-20 minutes until pastry is golden and puffed.
Allow to cool slightly before serving.