Just keep unscrewing the end weights till they come out, the nut inside will fall out when you tip the bars up or, if still fitted to the bike, blow compressed air down the hole and the threaded bit will come out the other end or, as I did when I unscrewed the bar end the wrong way, shoved the pressure washer nozzle there and give it a blast.
Just have a rag close to the other end to assist in catching the offending article as it shoot out or it will disappear in the manner of all small items that ping off as part of your cunning plan.