There are two key techniques to finishing. First, know which end of the line is favored (in other words, which end is the farthest downwind and closest to you). At the start, you wanted the end of the line that was closest to the weather mark, but now you want the end that's closest to the leeward mark so you don't sail any extra distance.
As they get to the line, bigger boats tend to "shoot" the line. In other words, when they are about a boatlength from the line, instead of continuing to sail upwind, they'll head up into the wind and let their sails luff as they coast their way upwind to the finish. While this tactic makes sense on big boats with keels, it doesn't make a whole lot of sense on smaller boats such as Optimists.
One last note regarding finishing - don't forget to thank the race committee. If you're too far away from them for them to hear you, give them a wave. The race committee members volunteer their time to run races and regattas for you, and thanking them shows your appreciation for their efforts. As a side note, the mark boat, registration, housing committee, safety inspection, dance chaperones, and all of the other folks that help make regattas happen are volunteers as well, and also deserve your thanks.