Workaround for popup instantly closing again because of click-event that still has the close method registered - would be better to add a delay before registering the eventListener and make the removeEventListener calls work.