Blanch green beans in boiling water 4 minutes, then drain. Ice water bath if you have it.
Melt butter in a skillet over medium heat. Add sliced onion and cook until deep golden, about 12 minutes.
Add mushrooms and garlic; cook 4 minutes more.
Sprinkle flour over veggies and stir 1 minute. Pour in milk and broth, whisking until sauce thickens.
Stir in beans, salt, pepper, and cheese if using. Transfer to a 9x13 baking dish.
Top with French fried onions and bake at 350°F for 20 minutes until bubbling and topping is crisp.