I need to disable just the close button (minimize and maximize should be allowed) temporarily.
Every solution I\'ve tried disables all the buttons
Although it may be possible, I have never seen it. That's just not how programs do it and your program should follow known patterns so it's users know how to use it.
If closing a program is temporarily not possible, show a message explaining why, when your user tries. This way you can present a solution ("you must first do...") instead of simply presenting a problem ("cannot be closed").
In addition, there are multiple ways to close a form. You are only looking at one of them. Disabling one will still leave the others and you would want to prevent all options that lead to closing your window, so it's best to handle the Closing event appropriately.