Please improve the grammaticallity of the given sentence
Some of the students finished school, and they are going to leave Canada and go back to their countries, so they took pictures after finished each class.
Some of the students finished school and were going to leave Canada and go back to their countries, so they took pictures after they finished each class.