Melt the butter in a saucepan and add the sliced onion. Gently cook 20 minutes without stirring too much. Brown the onions well.
Add the thyme and garlic and cook one more minute. Add the wine and scraped up any burned onion from the bottom of the saucepan. Add the stock and season with salt and pepper. Simmer 10 minutes.
Preheat oven to 220 degrees C. Divide the soup between four bowls. Place a slice of bread on each, top with cheese and bake until cheese is bubbling and browning.