A running PowerFactory instance can be terminated via DPL by using the ComExit command.
Example:
object cmd;cmd = GetFromStudyCase('ComExit'); cmd.Execute();