I don't really know what the right stopping criterion in the Dijkstra algorithm is for the case of multiple sinks. If there's only one sink state, then you are supposed to break whenever you encounter the sink state. My implementation (as written) only stops once you've check all of the nodes in the queue.