1. Negotiate before, not during
A negotiation conversation covers what you are both interested in, hard limits, and soft limits. This works best calm, sober, and unrushed.
2. Choosing a safeword
A safeword means stop, right now, and is not easily confused with anything said during a scene. Many people use a stoplight system, such as green, yellow, and red, for exactly that reason. Agree on it in advance, and agree that it is honoured immediately.
3. Check-ins and aftercare
Checking in during a scene is not a sign it is going badly. Experienced partners do it as a matter of course. Afterwards, aftercare matters as much as anything that happened before it.