Trying to fix the popup not closing bug