Created attachment 134067[details]
Sample starting document (DOCX)
Attaching an overly simplistic sample mail merge starting document (DOCX) and address list (ODS, but format doesn't matter), but the behavior is independent of the content.
- Open the starting document (DOCX).
- Start mail merge wizard.
- Jump to step 3. Insert address block, open Select Address List... and after clicking Add..., select the address list spreadsheet. Click OK in the dialog.
- Cancel mail merge wizard, and close Writer without saving anything.
- Restart LibreOffice, and check databases in Tools -> Options...; LibreOffice Base -> Databases.
=> There is a database with the address list spreadsheet file name ("data source" in the sample), and something like this for database file: "vnd.sun.star.pkg://file:%2F%2F%2FD:%2Fbug%2Fmm%20document.docx/EmbeddedDatabase"
Note that no such entry remains if the starting document is an ODT.
While nothing was saved in this case, the same thing happens if the document is saved as DOCX/DOC, as embedded database doesn't get saved in MS Office formats, yet the database remains in the list afterwards.
It would be great if defunct embedded database entries were removed on start in general (a crash with the file open could leave one even in case of ODTs).
Observed using LO 5.4beta2 / Windows 7.

Other way to trigger this issue:
- Open the starting document (DOC or DOCX).
- Start mail merge wizard.
- Jump to step 3. Insert address block, open Select Address List... and after clicking Add..., select the address list spreadsheet. Click OK in the dialog.
- Click Finish.
- Close document without saving, or save the merged documents, or even the original, and close it.
=> Verify that in 'Tools -> Options...; LibreOffice Base -> Databases' that there is a database that points to the supposedly embedded database in the initial DOCX (the database connection can also be checked in Writer in View -> Data Sources).
The leftover database entry can be manually deleted in the Options dialog (could be useful for testing).
To reiterate, not embedding the database connection in the merged and saved DOCX is fine (that'd be a separate enhancement), this issue is only about the lingering entry in Registered Databases list.