How to automatically remove a contact from specific group, if end date is added to specific relationship
You can use civicrm "Smart Group" option for that purpose. Like this:

Go to Contact Advanced search, set the relationship type you want as a filter and other filters if you want, like contact type, etc.

After search is complete, select the All X records radio option in "Select Records" field. Then you in Actions dropdown menu Create Smart Group. Smartgroup automatically updates its contacts list based on the criteria you had set.

Hope this helps.