function pctOnClientShutdown()
%

% Copyright 2020 The Mathworks, Inc.

% Close down open local process pools.
try
p = gcp('nocreate');
if isa(p, 'parallel.ProcessPool')
    if strcmp(p.Cluster.Type, 'Local')
        % This is more brutal than delete(p), but triggers the necessary cleanup on the workers,
        % and is faster and allows us to bail after 5 seconds.
        wait(p.parfevalOnAll(@dctFinishInteractiveSession, 0), 'finished', 5);
    end
end
catch 
    % Swallow. We're shutting down anyways, and we don't want this error to
    % prevent shutdown.
end

end

