What is the "natural" ending of a work of art? How to close something whose premise, whose founding conceit, is that, like life, it doesn't end? The Russian formalist critic Viktor Schlovsky praised Chekhov for his "negative endings", by which he meant, in part, the way his stories frustrate our sense of tidy form by refusing to end: "And then it began to rain."

The other day I watched the Ethan Hawke-Julie Delpy film Before Sunset, which came out last year, because I was curious about the idea of a movie whose rather literary ambition is to have a Chekhovian openness. It's the sequel to Before Sunrise (1995), in which the Hawke and Delpy characters, Jesse and Celine, meet on a train to Vienna. They stay up all night talking and swear to reunite in six months. The sequel takes up the story nine years later. Jesse is in Paris to read from his novel (a nice fantasy, but let it pass), and sees Celine in the audience. The couple again spend a few excited hours together, before Jesse's plane is due to leave. They wander through Paris, talking and flirting, as the sun begins to set. (The timing is wrong, you can't take a night flight from Paris to New York, but let that pass.) They did not meet six months after the Viennese night. Jesse is married, while Celine has had unhappy relationships. Neither has ever reached the pinnacle of that one night nine years ago.

It's not a bad film at all, though it hardly merits the ecstasies that have been poured over it in the press and on the net. Hawke, Delpy and the director, Richard Linklater, wrote the script in five months and shot the entire thing in 15 days. The film is almost set in real time, and at times the writers mistake the drift of ordinary life for a complete relaxation of shape, form and dramatic interest. But at its best it has a wistful, improvisatory feel that does indeed feel lifelike, and feels true to the fragile happiness of the two characters. Hawke has spoken of making many more films, creating a kind of life-project in which the two actors would reunite every so often over the coming decades, blending the fiction of the films' storylines with the actuality of their own real-life maturation.

What most interested me, however, was that it was a film improved by a beautiful ending, so that as soon as it was over it began to seem a better film than it had seemed while it was running. (And this wasn't just because it was over...) Jesse has agreed to go to Celine's apartment. She puts on a particularly lovely Nina Simone song, "Just in Time", and dances along to it. Suddenly she turns to Jesse and says, "Baby, you're going to miss that plane." Jesse shrugs, says: "I know," and then gives a foolish smile. The film ends here, as Nina sings those ravishing words: "You've found me just in time / And changed my lonely nights / that lucky day." Whether these lovers have indeed found each other just in time is the open question of the film's ending, as it is the open question of the last, luminous paragraph of Chekhov's "Lady with a Little Dog".

It is one of those endings that reformulates everything that has gone before, giving it a final power it had not possessed before its ending. This is rare in art, surely; unsuccessful endings are the norm. You could say, as a rule, that the novel, for instance, is a form that doesn't want to end, and that generally contorts itself into unnatural closure. How often we feel of long novels especially, that their last 50 or so pages are mechanical and overwrought, that the rhythm of the book is speeding up as it reaches home. Even great novels have disappointing endings, like War and Peace and The Portrait of a Lady, in which the novelist seems to admit to us that, having attempted to make his novel almost continuous with life, he cannot really wrench it away from that continuity by bringing it to a close. There is an interesting analogy with psychoanalysis, which "slows down" the treatment of the analysand so that analysis often takes years and years; but then, after so many years, the analysand often finds the termination of treatment a bruising affront to continuity.

Of course, the basic conundrum that attends any organic process is that in one's beginning is one's ending: the entire length of a novel or symphony can be said to be a kind of drawn-out ending. This dilemma is more apparent in music than in writing, perhaps, because the final chord, the resolution, of a piece of music generally sounds so banal, so static, so formulaically harmonious. One often feels, especially in Romantic music, that the composer resents having to shuffle the music toward its finale; Wagner built massive structures on suspended chords, on the deferral of resolution. Mahler is his faithful student in this regard. (The fade-out, in popular music, is a brilliantly shifty way out of this problem.) Schubert's Grand Duo sonata in C for four hands wittily plays around with its audience - it seems to be about to end again and again, only to take off for another round of complication and development. Beethoven's last piano sonatas are fascinating in part because the structure is that of theme and enormously elaborate variation; and Beethoven's variations are so fertile, so ingenious, so chromatic that they seem potentially infinite, a statement of limitlessness.

Perfect endings, whether of the open Chekhovian kind, or of the positive and closed kind, are rare and to be cherished. One of the most beautiful last lines must occur in To the Lighthouse: "Yes, she thought, laying down her brush in extreme fatigue, I have had my vision." For that is what we want to be able to say at the close of every novel. Lily has finished her painting; and Woolf has now finished her open and fluid novel, which we, as readers, have helped to "paint". In this case, we have all indeed had our vision.

· James Wood's collection of essays, The Irresponsible Self: On Laughter and the Novel is published by Jonathan Cape.