STOPPING A SERVO

this is the code

 #include <Servo.h> 

int ledPin = 13;
int inputPin = 9;
int pirState = LOW;
int val = 0;

Servo myservo;

int pos = 0;
//long interval = 1000;
//unsigned long lastSpuit = 0;
 
void setup() { 
  
  myservo.attach(8);
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input

  Serial.begin(9600);         // Start serial communication at 9600 bps 
 
} 

void loop() { 
  
   val = digitalRead(inputPin);  // read input value
   
  
  if (val == HIGH) {      
    
    digitalWrite(ledPin, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    
    myservo.write(90);
    delay(1000);
    myservo.write(pos);
    delay(1000);
    
  }
  } 
  else {                           

     digitalWrite(ledPin, LOW); // turn LED OFF
      if (pirState == HIGH){
      // we have just turned of
    Serial.println("Motion ended!");
      // We only want to print on the output change, not state
    pirState = LOW;
    
     myservo.write(pos);

 } 
} 
  }

attached is the picture