In a thick-bottomed saucepan, sweat the onions in 2 tablespoons of the butter over medium heat until the onions are about one-third of their original volume and nicely colored. This should take about 15 minutes. Add the stock, sherry, vinegar, thyme, and bay leaf and season with salt and pepper. Simmer slowly for 20 minutes to blend the flavors.
Swirl in the remaining butter and correct the seasoning (with vinegar, too). Use immediately, or store in the fridge for up to 5 days.