Close and delete all related dialogs when main window closed
Fix crash on quit
add "export to R" to custom sql dialog and fix sqltextedit