Heat the oven to 375°F and grease a 2-quart or 9x13-inch baking dish.
Bring a large pot of water to a boil and add the salt. Cook the green beans for 4 to 5 minutes, until bright green and crisp-tender. Drain, then plunge them into ice water to stop the cooking. Drain well and pat dry.
Melt the butter in a large skillet over medium-high heat. Add the mushrooms and cook for 6 to 8 minutes, until they release their liquid and start to brown. Add the onion and garlic and cook 2 minutes more.
Sprinkle the flour over the mushrooms and stir for 1 minute. Slowly whisk in the broth, then the milk. Simmer, stirring, for 3 to 5 minutes, until the sauce is thick enough to coat a spoon. Season with salt, pepper, and nutmeg.
Take the skillet off the heat and stir in the green beans and ½ cup of the fried onions. Spread everything in the baking dish.
Bake for 20 minutes, until bubbling. Top with the remaining fried onions (and Parmesan if using) and bake 5 to 10 minutes more, until the onions are golden. Let it rest 5 minutes before serving.