Hi Sachin,
I think the data retrieved from the JDBC goes to any SAP ECC or third system, from these systems you can check if there is no more data during X time and to stop the JDBC externally. Check these blogs:
SAP PI : Start/Stop Communication Channel using Webservice
Start/Stop a communication channel from an ABAP program using the external control switch
Regards.