Minor modification of finishOpenedActivities()