Mary’s grandmother died when she was 12.

Always make sure the subject agrees with the verb – or at least try to avoid confusion! A better choice of words would have been: ‘When Mary was 12, her grandmother passed away’.