The agreement ends a six-year legal battle over seismic safety at Japan’s oldest active student dorm.