When you click the button, the button steals the focus from edit. So the first thing that happens is that the edit control loses focus (which triggers OnExit event). Only then button's OnClick event executes. So you cannot prevent OnExit inside button's OnClick code, it's too late.
In any case if all controls events are handled in same procedure, you can simply exit if the sender is tedit
Would not work. If same procedure is assigned to Edit.OnExit and Button.OnClick, this procedure will be executed twice - first time sender is Edit, and the second time sender is Button. In the first call, when sender is edit, you don't know that the button is clicked (you can check which control has focus, but even if it is the button you do not know that it is clicked) and application will close, and in the second call it is too late.
It is same problem as if two separate procedures are used.