As mentioned by Sam, you must leave the flue damper open until the wood has completed burning or is fully extinguished. This is really an answer to your follow up question. I tried to address it briefly in comments, but ran out of allowed characters. I also hate multiple run on comments and the inability to break my comment into paragraphs, so I'm making this an answer.
Not only must you leave the flue damper open, but you must maintain an adequate combustion rate so the established draft up the flue continues to evacuate smoke as long as the wood is burning. The problem can and will arise where the combustion slows so much that the flue cools and the draft is blocked by cold air. Now smoke will have no where to go but back into the house.
The best way to prevent smoke in the house is to have the fireplace ducted to use outside combustion air. This way, the combustion chamber is sealed from the house and only very small amounts of smoke can leak through the joints in the doors.
Outside combustion air is not always a viable option. The next best option is to configure the combustion air openings and arrange the remaining coals to burn as rapidly as possible before retiring for the night. Thus the flue will stay hot until the wood is fully consumed.
A reasonable start point is to break up the remaining large chunks of coals and arrange them in a pile directly below the front edge of the smoke shelf. If chunks of wood are not burnt enough to break up, place them in the center of the pile and push smaller pieces up against the big ones. Your ability to do this will be limited by grate or andiron configuration. You don't need to go through extraordinary measures, just do the best you can. Close the glass doors and leave the combustion air vents wide open.
If you still get smoke backing up, experiment with leaving the doors ajar. You will provide more combustion air for faster burning, but also allow a free path for smoke to enter the house. If you restrict the combustion air further, you restrict the ability for smoke to enter, but you increase the chance of the flue cooling before the burn is complete. It's sort of a Catch 22, but hopefully you'll find the optimal arrangement.
An alternative approach if you plan on rekindling the fire in the morning is to re-stoke the fire a bit before retiring. Once the wood is fully charred and embers are forming on the edges, close the doors and restrict the combustion air intake enough to really slow combustion, but not so much that the fire chokes itself out and you're left with a bunch of cold charcoal and a strong creosote smell. The idea being by morning there's still embers burning and the draft is still established. Restarting the fire should be very easy. It will take some experimentation to determine the right combustion air volume. It varies by fuel load, log size, wood type, moisture content, outdoor air temperature, etc.
Another trick is to not fully clean out the ash all the time. The embers burn hotter on a thick bed of ash than they will on raw fire brick or a thin ash layer. This will help keep the draft established.
Accidental smoke entry seems to be inevitable with wood burning. But it should be just that, an accident, not a regular occurrence. It may take a little trial and error, but you should find a way to operate your fireplace so that you can enjoy it without much concern for smoke odors in the house.