Don't consider last stage of pipeline a subshell for Ksh/Zsh

Also fixes the problem where pipelines were considered a single subshell.