MainWindow: Improve SQL tab behaviour

Don't allow opening and saving when no database file is opened.

Close all tabs when the database is closed.