If use the built-in dialogs and goes to the warning advise, if you click to “Save and quit from Custom Screen” you get the connection lost and show a button for go to server list ignoring you run this in a Singleplayer world
Related issues
relates to
Comments

Can confirm. It would be more accurate if the button said “Save and Exit World” if the world is singleplayer/self-hosted LAN or “Disconnect” otherwise, and in the former case, the player would be brought back to the singleplayer world list and not the server list.