How to know when serial has finished sending

Yes, you need another approach. I built an example for you:

#define MAXDATA 50
#define TIMEOUT 10
void setup()
{
  // This code will only run once, after each powerup or reset of the board
  Serial.begin(9600);
}

long timeoutOver;
char data[MAXDATA];
  
void loop()
{
  // This code will loops consecutively
  boolean somethingReceived = false;
  int pos = 0;
  
  if(Serial.available())
  {
    somethingReceived = true;
    do
    {
      while(Serial.available())
      {
        data[min(pos,MAXDATA-1)] = Serial.read();
        timeoutOver = millis()+TIMEOUT; pos++;
      }
    }
    while(millis()<timeoutOver);
    data[pos] = '\0';
  }
  
  if(somethingReceived)
  {
    // Do something
    Serial.print("Received: ");
    Serial.println(data);
  }
}