There is a setting inside the Sequence Settings to set these rules, but you may also set more defined rules using SmartList and the Auto-Unenrollment Options.
Check out this article on How to Unenroll Prospects from a Sequence for specifics on each approach above!