Whats the best way to close a websocket?

pracas
I'm trying to subscribe for a script till a specific ltp is reached beyond which i want to unsubscribe and close the websocket to be opened later. I'm struck on closing the connection. The following code doesn't work and throws the following error. What am i missing?
builtins.TypeError: on_close() takes 0 positional arguments but 3 were given

def on_ticks(ws, ticks):
# Callback to receive ticks.
print("#######################")
print(ticks[0]['last_price'])
print("#######################")
global tick_count
tick_count = tick_count +1
print("TICK COUNT : ")
print(tick_count)
if(tick_count > 1):
print("inside if")
ws.unsubscribe([53718535])
ws.close()

def on_connect(ws, response):
# Callback on successful connect.
# Subscribe to a list of instrument_tokens (RELIANCE and ACC here).
try:
ws.subscribe([53718535])

# Set Crude to tick in `full` mode.
ws.set_mode(ws.MODE_FULL, [53718535])
except Exception:
print(Exception)

def on_close():
print("here")

# Assign the callbacks.
kws.on_ticks = on_ticks
kws.on_connect = on_connect
kws.on_close = on_close

kws.connect()
print("################ HEREEEEEE #############################")
tick_count = 0
kws.connect()
This discussion has been closed.