Windows needs this if-clause protection, since it’s using spawn for multiprocessing.
If you don’t protect your code, the script will be called multiple times executing all module-level code, thus yielding an error.
Have a look at the Windows FAQ 22 for further information.