Preheat oven to 400°F. Butter a 2-quart baking dish.
Melt the 2 tablespoons butter in heavy large skillet over medium-high heat. Add mushrooms and onions and gently sauté until with the lid on, about eight minutes, until the mixture is tender and starting to brown. Check now and then and stir, adding a little water if they seem dry. There’s no hard and fast rule as to how much water, just add a tablespoon or two, stir up any color off the bottom of the pan, and add the lid again.
Once the mushrooms are turning golden brown and the onions are softened, remove the lid and continue to cook, stirring now and then, until excess liquid has evaporated. Continue to cook a minute or two longer until the mushrooms and onions are dark golden. Add garlic and thyme and heat until the garlic is fragrant and has lost its raw taste. It’s ok to taste; make sure the garlic is cooked through and add a little salt if needed. (May be made 1 day ahead. Cover and refrigerate.)
While the mushroom-onion mixture is cooking, prepare your potatoes and set aside. In a large bowl, whisk broth, cream, wine, salt, and pepper to blend and set aside.
Use 1/3 of the potatoes as the bottom layer, top with half the mushroom mixture, and about 3/4 cup of cheese. Pour half the cream mixture over the top.
Add a second layer of potatoes, the rest of the mushroom mixture, and another 3/4 cup of cheese. Top with the last layer of potatoes and pour the remaining cream mixture over the top. Reserve the remaining cheese.
Cover loosely (a piece of foil just laid over the top is ideal) and bake until potatoes are just tender and the sauce is bubbly, about an hour. Check by piercing the center with a knife. There should be no resistance.
Top with the remainder of the cheese and bake uncovered for another 15 to 20 minutes until the cheese is golden brown. If necessary, the dish can be run under the broiler to brown.
Straight from the oven, the gratin will seem very liquidy. Let stand 20 to 30 minutes before serving; the texture will be perfect.
Notes:
There are two options for making ahead, either assembling the day before and baking the next day or partially baking the day before and finishing the next.