Fix bug causing reading next frame not to stop.