Preheat the oven to 400°F or 200°C and grease a 6 to 8 cup muffin tin.
Sauté onion in oil or butter over medium heat for 3 to 4 minutes, then add garlic and cook 1 minute.
Add mushrooms and thyme and cook 5 to 7 minutes until moisture evaporates and lightly browned.
Stir in flour, then slowly add broth and cream, cooking until thick and spoonable.
Remove from heat, stir in Gruyère, season with salt and pepper, and cool slightly.
Roll out puff pastry, cut circles, and press into muffin cups with a slight overhang.
Fill pastry cups with mushroom mixture and fold edges or top with pastry if desired.
Brush with melted butter and bake 20 to 25 minutes until puffed and golden.
Cool for 5 minutes, then remove and serve warm.