opengl – Collision detection stop movement

I am making a simple first person 3D game in OpenGL with C++. I am just wondering on how you make an object stop moving when it collides with another object. This is what I am using for detecting collisions:

a = object1
b = object2
w = width
object1 is moving on X,Y,and Z axes from user input

if( a.x + a.w > b.x && a.x < b.x + b.w )
(and the same thing for X, Y, and Z axis)

After detecting this collision how would I make “object1” stop moving?