If a project has a completed activity with the latest end date then its end date is taken from the activity's.
In order to change a project's end date you just have to change the latest end date of the closed activity.
The online help describes the relationship at:
Project start and end dates
The same rule is for parent activity and its children activities:
Activity start and end dates