Pre-ます-Form VERB + 終わる as “finish VERBing”
The verb 終わる can be used in conjunction with another VERB in its Pre-ます-Form to form a compound verb that means to “finish VERBING.” Although 終わる is an intransitive verb, the resulting compound verb becomes transitive or stays intransitive depending on the VERB that is used in conjunction (the first verb determines whether the resulting compound verb is intransitive or transitive and 終わる is always the second verb in the form Pre-ます-Form VERB + 終わる so it always conforms to the other verb used). 終わる is mostly used with transitive verbs in this grammar construct.
Shukudai o shiowatta ato de yuushoku o chouri shimashita.
(After I finished doing my homework, I made dinner.)
Yatto essay o kakiowarimashita.
(I finally finished writing my essay.)
Sugu ni heya o souji shiowaru.
(I will finish cleaning my room soon.)