In a large cast iron skillet over medium heat, heat 1 tablespoon of oil along with 1 tablespoon of butter. Add the mushrooms and sauté for about 5 minutes until tender. Remove and set aside in a medium bowl.Heat the remaining 3 tablespoons of butter along with the 1 tablespoon of oil and sauté the onions for 5 minutes. Add the dried thyme and sugar and continue to cook for 25 minutes on medium low heat. Make sure to stir the mixture every 5 minutes or so. If the onions are caramelizing too fast, turn down the heat a little more. Add the balsamic vinegar to deglaze the pan, allow the onions to soak it all in. Turn off heat. Add the onions to the mushroom mixture. Season with the garlic powder and salt and pepper to taste, stir to combine. Allow to cool to room temperature. Mixture can be kept in an air-tight container and refrigerated for up to 48 hours at this point. Allow to come to room temperature before proceeding. Add the gruyere cheese and mix well.Position two racks in the upper and lower thirds of the oven. Preheat the oven to 400 degrees F. Line 2 baking sheets with parchment paper or silicone mats.Using a knife or a pizza cutter, cut the puff pastry into 2-inch squares and place them on a lined baking sheet. Make sure the puff pastry is cold before proceeding. If not, allow it to rest in the refrigerator for 10-15 minutes before proceeding. Using a pastry brush, brush the beaten egg on the squares. Place a tablespoon of caramelized onion mixture in the center. Bake for 20-25 minutes, rotating the pan halfway in between until crisp and golden brown. Let cool slightly before serving.