For those wondering how to prevent the editor from opening the source file after a $finish/$stop (saw a comment above, my reputation too low to reply):
set PrefSource(OpenOnFinish) 0
set PrefSource(OpenOnBreak) 0
Source:
ModelSim® GUI Reference Manual, v2024.2