fixes #13816 Modal dialog closes when dragging and releasing mouse button outside dialog

Fixes #13816.