Regulation by a chaperone improves substrate selectivity during cotranslational protein targeting