Added stop_encoder function