Close the popup after the api call returns