(a) A discontinuance or nonsuit shall not affect the right of the defendant to proceed with a counterclaim theretofore filed.(b) A counterclaim may not be terminated, in whole or in part, by the defendant, except by discontinuance or voluntary nonsuit, and subject to conditions similar to those applicable to the plaintiff.