Okay, I fixed the issue by placing the popup code in a separate procedure. That way, when you click "Close" to run the trigger code "APPLY "CLOSE" TO THIS-PROCEDURE", only the popup gets closed.
If you don't put the popup in a separate procedure, the trigger code of "APPLY "CLOSE" TO...