In a large skillet, melt the butter over medium to medium-high. Add the mushrooms and cook, stirring occasionally, until browned, 3 to 5 minutes. Add the shallots, garlic and thyme; season with salt. Cook, stirring occasionally, until the shallots soften, 2 to 3 minutes more. Sprinkle with the flour; stir 1 minute. Stir in the sherry, then the half-and-half and stock. Bring to a bubble and cook, stirring occasionally, until the sauce thickens, about 3 minutes. Season with white pepper. Add both cheeses; stir until melted, about 2 minutes.
Meanwhile, bring a large pot of water to a boil for the pasta. Salt the water, add the pasta, and cook 5 minutes. Add the green beans and cook until the pasta is al dente, 2 to 3 minutes more. Drain the pasta and green beans; mix into the mushroom cheese sauce. Transfer to a casserole dish and top with the fried onions.