You need to create an order. I think something like this might be a good start.
You need boolean that will lock the unit from picking. You also need a variable Order. This is for units that player has selected.
Repeat "selected" count, pick nearest Units to MouseTarget, units boolean Ready = false. Then set that boolean to true and varOrder to loopindex. Now every unit has it's order number, so it might be easier to figure out how to get them pass trough.
Maybe that will help. Also,have a look at Ro0j example.
The issue I see with this is that the nearest unit may not be the one that needs to move first.
Whenever you click to create a path, it removes the previous nodes, so if the units are following the nodes, and you click again in the same location or nearby, the previous nodes disappear and you get one or so nodes at the place where you clicked.
You would have to store/save/update each path nodes in some way so that they all connect and go to the destination from the perspective of each unit.
I don't know how much processing would occur to create a path for each unit- but that is one way to ensure each unit has a node to go to (you could put the path-following sprite in a container with the unit so that each unit has a path-following sprite).
Maybe at that point, you could find which unit has a shorter path, and move them in that order (short to long). If there is any congestion, pause the longer path units that are behind the congested area/unit.
edit: this is also why I suggest a dijkstra, because those take less processing, and you get data that an unlimited number of units can rely on. I made a dijkstra plugin in the past for something I was working on and I never released it because it wasn't meant for public use. I'd have to clean it up and figure out a way to make it more user friendly.. Maybe I'll do that in the future, but I have other things to focus on.
Using paths for each unit might be a workable solution, but you would have to test it out.