Share via

PSHost.SetShouldExit(Int32) Method


Request by the engine to end the current engine runspace (to shut down and terminate the host's root runspace).

 abstract void SetShouldExit(int exitCode);
 abstract void SetShouldExit(int exitCode);
 abstract void SetShouldExit(int exitCode);
public abstract void SetShouldExit (int exitCode);
abstract member SetShouldExit : int -> unit
Public MustOverride Sub SetShouldExit (exitCode As Integer)



The exit code accompanying the exit keyword. Typically, after exiting a runspace, a host will also terminate. The exitCode parameter can be used to set the host's process exit code.


This method is called by the engine to request the host shutdown the engine. This is invoked by the exit keyword or by any other facility by which a runspace instance wishes to be shut down.

To honor this request, the host should stop accepting and submitting commands to the engine and close the runspace.

Applies to