First and foremost, try to get a good range of grammatical techniques when writing the essay for example subordinating conjunctions or adjectival nouns. Demonstrating your knowledge of these techniques should also appear natural; don't force something that doesn't work in your head. This grammatical variety will also help to avoid repetition. However, the most important thing to ensure good grammar is rereading and checking the basics, e.g. genders, adjectival endings and conjugation of verbs. You might find it easier to spot your own mistakes if you go back and check/complete other parts of the exam paper first. The basic grammar is where you can lose lots of marks, so getting this right is crucial, the grammatic variety is usefull to push the mark even higher.