Unfortunately apps don’t care. Waze lingers up to 40 minute after traveling in the background and that’s with supposed in app only mode.
If Waze is using it for up to 40 minutes after traveling, you need to decide if you want to know where the cops are or if you want Google to know where you are.
I always force quit Waze at the end of the trip so that it (1) stops tracking me and (2) I don't waste my phone's battery life on tracking me
It is one of the few app categories that can do that; the other is VOIP.