D&D is an RPG. A role playing game. Characters play a role in a story. That story is one that the DM plans and the players improvise through. The first role of being a good improvisation partner is NEVER SAY NO.
You had a plan. They came up with something unexpected. Your job: DON'T SAY NO. Find the fun in their plan and let it go. It doesn't mean you need to let it succeed, but build upon their ideas and tell a fun story.
If you let them perform their plan, their job is: DON'T SAY NO when they hear how you decide to resolve it. If you decide it is an autokill - ok. If you decide it deals a bunch of damage - they need to say, "OK". If you decide they saw the 5 ton rock coming and escaped - they need to say ok.
The most important thing is to make sure it creates an awesome story that everyone enjoys. If the BBEG escapes, make sure the twist is fun for the PCs - and earned. If you can't, don't let him escape. If you let him get nailed, decide whether to go insta-kill or take damage. If taking damage, make sure it is meaningful based on the circumstances and sell it to the PCs with a great description. If you don't think the PCs will buy any level of damage - give them the insta-kill... and figure out how to continue the story from there.
When I was very young I designed a giant ice maze dungeon. It was meant to be a major delve with the PCs spending weeks of gaming in it. I was so proud of all the different things inside of it - the ecology and interaction between different areas. The fun traps. The stimulating puzzles... and a bunch of monsters I'd built from scratch. The climax was a massive battle scenario before they exited the dungeon on the other sizide of the maze and would be able to see the sun for the first time in so long... The PCs arrived at the dungeon, took one look, asked themselves what was stopping them from just walking over the top of it... and I was crushed. It was such an obvious answer and it slipped right past me.
So they walked past it. I kept a straight face and didn't reveal until a year later that I had expected them to adventure through it - and how much time I'd wasted. The most important thing to me, as I'd learned from reading the DMG, was to make sure we were telling a good story. And the best thing for the story, when they saw the path, was to ley them use it. While I've learned a lot and am less likely to make a similar mistake today\, if I did, I would do the exact same thing.