1. If the engine gets minimized (not closed!) when you press escape it cuold be that another program has got a hook on escape. Ensure on_esc is really null. You can do that by writing "printf("%d",(long)on_esc);" Another function could have set the on_esc pointer.
2. If calling the dll every frame causes a significant slowdown then that slowdown is of course caused by the plugin. If you comment the line out, that calls the dll function, does the fps go back to normal then?