Serial communication between two Arduino Nano’s

if (incomingByte == 'Z') {
clearBuffer();
}

and send the "Z" before switch off.