Close command channel when shell terminates, fixing #279