Preheat the oven to 375. Butter a 9 x 13 rectangular baking dish and set aside.
Bring a large pot of water to a boil, and keep at a simmer until ready to cook the pasta.
Meanwhile, prepare the onions. Melt two tablespoons of the butter over medium heat in a large saute pan with a lid or large saucepan or stockpot. Add the onions, garlic, thyme, and 1 teaspoon salt and stir. Cook for 5 or 6 minutes, stirring occasionally, adjusting the heat if they start to dry out or brown too quickly.
Pour in the vermouth and stir, scraping up any bits stuck to the bottom. Partially cover, and cook for 20 minutes, stirring occasionally. The onions should be very soft and the liquid evaporated.
While the onions are cooking, cook the pasta in salted water until just al dente. The pasta will continue to cook in the oven, so be sure not to overcook it here. It should be drained about 2 minutes before the instructed cook time. Set aside until the onions are finished.
Add the remaining butter to the pot with the onions. Once melted, stir in the flour and cook over low heat for 2 minutes, stirring the entire time. Pour in the beef stock and stir vigorously to avoid any lumps. Bring to a simmer, stirring the entire time, then simmer without stirring over low heat for 4-5 minutes until slightly thickened.
Combine the pasta and the onions and taste for seasoning. Add fresh cracked black pepper and if it is needed, add more salt. Pour into the prepared pan.
Top with the cubed bread, pressing it down slightly into the pasta and onions, then scatter the cheese over the bread evenly.
Bake for 30 minutes until bubbling. Serve warm and gooey.