That's not anything to do with the game, Windows creates those buttons on every application window that opens on your computer.
I don't think JavaScript runs at a low enough level to be able to overwrite that functionality.
And, besides, it's not likely to achieve anything except annoying people who are trying to close the program. Just put the option to return to the title in your regular menu.
Technically speaking, it is possible to make the X button to do something, by listening to the close event. However, you shouldn't make the X button to take them back to the title screen, as this would be very annoying. It makes more sense for cases like the player didn't save for long periods of time (and offer to save).