France's Bryan Coquard won the Four Days of Dunkirk after claiming the final stage in a photo finish.