A group of Democrats voted with Republicans to advance a measure to end a 40-day shutdown, the longest in US history.