Lightbox: Fixed incorrect closing of AJAX popups.

Fixes #5594. Fixes #5391.
Merge pull request #5601 from pjackson28/fixlightboxajax

Lightbox: Fixed incorrect closing of AJAX popups.