Dijkstra terminates upon expanding the goal node. Also we use a priority queue in dijkstra (not a queue) so that we expand the node that has the least cost. So in your example A will never be expanded.
open list = [ S cost:0 ] // priortiy queue
pop S out of open list
closed list = [ S cost:0 ]
open list = [ B cost:1 ; A cost:5 ]
pop B out of open list
closed list = [ S cost:0 ; B cost:1 ]
open list = [ E cost:2 ; A cost:5 ]
pop E out of open list
// it's better to terminate when we reach the goal but if we don't
// it doesn't make any difference we are going to find the shortest path
// to other nodes
closed list = [ S cost:0 ; B cost:1 ; E cost:2 ]
open list = [ A cost:5 ]
pop A out of open list
// there isn't any nodes that we can push to open list
closed list = [ S cost:0 ; B cost:1 ; E cost:2 ; A cost:5 ]
open_list = []
Dijkstra push a node to its closed list upon expanding it because it assumes it has find the shortest path to it. So even if we don't terminate upon reaching a goal we will never expand A because it is in our closed list.