I don't know the sites that you are referring to so I can't say with certain what was going on behind the scenes, but I can perhaps explain how this happens within the scope of digital advertising.
What I believe you are referring to is a practice known as clickjacking, and this is sadly quite a common practice. See this OWASP page for more information.
Ordinarily when I detect this kind of behavior the clickjacking is used to falsely attribute your legitimate attempt to close a window with an advertising click, which essentially registers a click-through event on the would-be-visible ad. Generally [legitimate] clicks tell the advertiser that the ad (impression) was seen and interacted with by a [hopefully] real human visitor, and the advertiser rewards the publisher (the site that hosts the ad) with payment for serving the impression.
Unfortunately, in the malicious case of clickjacking attacks, the perpetrator gets paid and the advertiser's ad is never seen (though is inadvertently clicked on).
Hope this helps shed some light on what could be going on, but @bashCyper's answer is absolutely right, it is a threat and it is recommended to always keep your browser updated in order to protect yourself.
Additionally, clickjacking can also provide the attacker with specific information about you. Digital advertising is one of the most effective ways to recon potential victims because of the invasive nature with regards to the information that is collected. Information grabbed by advertisers after a click is registered can be: browser type, version, IP, OS, etc. All of which can be used to mount highly precise malvertising campaigns, which essentially attempt to deliver malware via digital advertisements that target specific browser versions with known vulnerabilities! See the below articles for more information about this.