One of my favorite tricks of writing is something I like to call "the loop." The reason it's my favorite is because it has the the triple-whammy effect of:
1) Getting me out of a major writing problem, specifically one that has to do with "How the hell do I end this thing now?"
2) Ties up loose ends that I may not have noticed were there before.
3) Makes me look like a writing genius.
So, just what is the "loop thing" you may be asking. It's really quite simple. If you take your character and put him or her up a tree and can't get said character back down again, loop yourself back to the beginning. I don't simply mean rewrite the beginning as your ending, but look for clues there that may help you finish the piece.
It's amazing what we, as writers put into our rough drafts without even realizing we've done it. Take for example, are there any details in the study that could become suddenly important? That candlestick that you placed on the wall during that party scene could become an effective offensive or defensive weapon later on. Even the way a character is dressed could become important if you need it to be. Scarves can be tied, as can belts, around things other than the original place that was intended. For female or TV MC's, perfume can be sprayed in someone's eyes and a nail file can be used quite effectively for things other than a weapon, but to whittle away at an otherwise impenatrable barrier.
Did you have a creaky floorboard that annoyed a character earlier? Could there possibly be a reason it's creaky? Maybe there's something underneath the floor that could be used as a hideaway or escape route. Granted, this technique can seem like deus ex machina if not handled well, but if you go back later and pepper your story with rumors of hidden treasure or underground railroads the ending may not only shock and surprise but will have readers saying "Wow! The writer planted clues about this all over the place!"
Yeah, let them think that. It's our secret right? ;)