Indeed very important that the window is up completely when you open the door. If it isn't, the system won't close the door. If that doesn't help, reprogram it using the guidance in the owner's manual.
This has been happening to me lately almost on a daily basis now except on the drivers side door. I always have to hold down for 5 seconds and hold up for 5 seconds for the window switch. If I don't do this the window stays open about an inch. A bit annoying.