Fix twitchy Bootstrap modals, to avoid runaway JS.

This is a fix for those occasions when we have multiple modal elements,
usually due to the event-blocking screen over a popup. See inline
comments for more background on this known issue.