Use the "End Stream" button in YouTube Studio
Before I start streaming, I open up the page for the stream in YouTube Studio. If you're in YouTube proper, you'll need to get into YTS by clicking on your profile image on the top right and then going to "YouTube Studio". Once you're there, look for "Create" > "Go Live" in the upper right. This should bring up a list of your future (or ongoing) streams, where you can get to the full page for your current stream.
This page can be pretty helpful (which is why I recommend keeping it open while streaming), since it allows you to preview your video feed before you go live or get helpful statistics such as how many people are watching at any moment.
If you haven't publicly started the stream, you'll see a button in the top right to "Go Live". If you're already streaming, you'll instead see an "End Stream" button:
Screenshot by Tosh
If you just stop streaming from your streaming software and close the tab, the stream won't be ended, which is helpful if you're having technical problems. For example, I was live-streaming an outdoor event and halfway through there was thunder and lightning and everything had to be moved inside. I had to shut down the computer running my streaming software but with minimal disruption I was able to resume the same stream when I was indoors.