DosStopSession ends one or all child sessions.
DosStopSession may only be issued by a parent session for a child session. Neither the parent session itself nor any grandchild, nor any other descendant session beyond a child session, may be the target of this function. DosStopSession may only be issued by the process that originally started the specified session (idSession) with DosStartSession.
DosStopSession may only be used to end child sessions that were originally started by the caller with DosStartSession specifying SSF_RELATED_CHILD for Related. That is, sessions started as independent sessions may not be stopped.
If the child session specified with DosStopSession has related sessions, these sessions will also be ended.
If a child session is executing in the foreground at the time it is ended, the parent session becomes the foreground session. DosStopSession breaks any bond that existed between the parent session and the specified child session.
A parent session may be executing in either the foreground or background when DosStopSession is issued.
Since any process executing in the specified session may refuse to end, the only way to guarantee that the target session has ended is to wait for notification through the termination queue specified with DosStartSession.