Create the main action button (or buttons), but keep the X
I worked in web-development for quite some time, this is mostly empirical knowledge that I gathered from user observation.
In many situations the user doesn't know what to do. Specially when presented with a choice. But even simple modals with a closeClose or OkOK button can be a challenge. The user often gets insecure about pressing the button. After all, a modal usually presents some kind of message (canwhich can be an error, disclaimer, a contract, etc) that you must read and agree to. Closing may lead to further undesirable actions (from the user perspective): Eg.: For example, "By pressing ok you agree to..." or "By pressing okOK the computer will make 1001 updates leaving it unusable for the next 3 days".
The X is looked at as "agnostic" and works as an "assuring" thing. When you use it you know you are closing the modal only. You're not making a choice and in principle that will not lead to any further developments.
As the comments already mentioned this behavior is being reinforced due to spam popups and modals. In some situations where a system modal is used the xX is the only safe option.