[Autonomous BlueROV2] MavLink/Ardusub help

Hello jacob
I have worked on making ROV autonomous recently and I succeed in running python scripts in RPI and control ROV with QGC connected. However, when I shut down my QGC and send a command move backward,

def move_backward(speed,timesec):
	print("movement_action")
	master = mavutil.mavlink_connection('udp:0.0.0.0:9000')
	master.wait_heartbeat()
	start_time = time.time()
	flag=1
	while flag :
	    finish_time = time.time()
	    if finish_time-start_time>=timesec:
	        flag=0
	    master.mav.manual_control_send(
	        master.target_system,
	        -speed,
	        0,
	        500,#405
	        0,
	        0)

The ROV will go backward without stopping. In fact, when QGC connected, the backward motion will last for timesec seconds.
I have tried input hold set command to stop the motion. However, only when I set r value will the rotation motion stop.

	    master.mav.manual_control_send(
	        1,#master.target_system,
	        0,
	        0,
	        500,#405
	        -speed,#r
	        0)

Input hold command doesn’t work for stopping descend, ascend, forward and backward motion.
I thought the manual_control_send command worked as the joystick input and they made equal effect, but when QGC disconnected, they were not equal.
Could you please give me some advice on this issue?
Any suggestions will be grateful! Thank you in advance!
EDIT:

def turn_left(master,speed,timesec):
	print("movement_action_left")
	# master = mavutil.mavlink_connection('udp:0.0.0.0:9000')
	# master.wait_heartbeat()
	start_time=0
	finish_time=0
	start_time = time.time()
	flag=1
	while flag :
	    finish_time = time.time()
	    if finish_time-start_time>=timesec:
	        flag=0
	    master.mav.manual_control_send(
	        master.target_system,#master.target_system,
	        0,
	        0,
	        500,#405
	        -speed,
	        0)

parameter master has been transmitted into the function, which is different from the backward function.