I found a pretty straight solution for this problem. You can add an event listener targeting an element by his id like so
window.addEventListener('mouseup',function(event){
var pol = document.getElementById('pol');
if(event.target != pol && event.target.parentNode != pol){
pol.style.display = 'none';
}
});