Destroy modalBar after last occurence is replaced

This is for issue #3748.

Note: the FindReplace.js code was copied directly from CodeMirror, so after we determine the fix, we should push a fix to CodeMirror.