Use:
wm protocol <window> WM_DELETE_WINDOW {#}
to prevent your window from closing when the [X] button is clicked.
More on this subject appears under the title "Catching window managed events".
Category Command