close connection and resources before onCompleted, onError