Please isolate your problem on CodePen and open a new issue on GitHub.
I'm using jQuery 1.9.1 and Twitter Bootstrap. On a whim, I looked at your example code and noticed you were using Zepto. I tried switching to Zepto, and this fixed the issue with your gallery, and it closed properly. However, it breaks Bootstrap.
Did you only test with Zepto? There might be an issue in jQuery, where you're selecting elements incorrectly, thus spawning too many events.