stop function

What i meant to do is to let the ship slow down and stop.

i know i can use this part of the code for but i have no idea how?

if self.keys[“accel”]:
heading_rad = DEG_TO_RAD * heading
#This builds a new velocity vector and adds it to the current one
#Relative to the camera, the screen in Panda is the XZ plane.
#Therefore all of our Y values in our velocities are 0 to signify no
#change in that direction
newVel = (
Vec3(sin(heading_rad), 0, cos(heading_rad)) * ACCELERATION * dt)
newVel += self.getVelocity(self.ship)
#Clamps the new velocity to the maximum speed. lengthSquared() is used
#again since it is faster than length()
if newVel.lengthSquared() > MAX_VEL_SQ:
newVel.normalize()
newVel *= MAX_VEL
self.setVelocity(self.ship, newVel)