In context Jesus is talking about the end times, the day of the lord, hence many who say on that day have we not done many works in your name? Since they are doing works or claim to do works in Jesus name, either
1. They were false miracle workers, Jesus said many false christ shall arise saying I am the christ and do signs and wonders to deceive the elect.
2. They did great works but had no charity. The apostle Paul said that works with out charity is of little value , nothing but a loud annoying noise, so they work hard but their heart is not right before the lord. A bit like a violinist, who tries to play, in a angry mood, the sound infuriates, rather than produce fruit of beauty.
3. They were charlatans who claimed to do miracles, but were false workers who made merchandise out of the sheep, fleecing the flock with vain words and false teachings. Hence Jesus calls them workers of lawlessness.
I think the second or third option is the most likely, for those of option 1 are likely to be false ministers of the devil, transforming themselves into agents of light and thus have no interest in the real Jesus, but serve a false Jesus. I have seen some of these workers of option 1, and they are very deceptive beyond imagination, one key to recognize these false workers is that they deny Jesus as the son of God, but see him as a master or teacher, they also have other new teachings. I tell you this so that you are warned in advance if you come across them, to not be sucked in by their apparent miracle powers. John said to test every spirit, ask whether Jesus/Yahushuah has come in the flesh.
, when these false workers or wolves from all options or rather option 2 and 3, who desire to escape judgment will not be granted Noahs ark of escape, whether that be the "come up hither", or to the desert prepared for the woman, where she is nourished and spared from the dragon.
So this verse is not talking about sheol, or eternal hell fire, because fire produces light, and a spirit does not gnash teeth. The parallel to these verses I believe are found in the book of revelation, where those who knew their masters will but did not do their masters will, will be beaten with many stripes.
Thrust out of the kingdom into outer darkness, where there will be weeping and gnashing of teeth.