How can I avoid getting locked knee in the future?

I sometimes get pseudo knee locking and it is very painful. Is there any exercises I can do to prevent it from happening again in the future? Thanks!

2017-04-11T00:37:33.809Z