There is no API endpoints for ending a users stream, as that’s entirely handled by the RTMP process itself.
At the end of an RTMP stream the NetStream deleteStream command should be sent, which will tell Twitch that it’s the end of the stream. Usually this is handled automatically by software like ffmpeg but if you’re running your own tool you may need to ensure you’re sending that, and that you’re gracefully shutting down whatever RTMP software you’re using.
If the stream just strops, without gracefully ending, then that’s what causes Twitch to use the disconnect protection as that is a disconnect, and no different from a loss of internet connection, or other failure that could cause a momentary outage.