How to make stepper motor stop moving

I am trying to use a stepper motor to make a hook lock mechanism, but once my code is entered, and the motor starts moving, it pauses, then starts moving again, and again and so on. How do I make it move a certain amount, and then stop moving altogether? The code that starts the motor is in the if statement.

#include <LiquidCrystal.h>
#include "IRremote.h"
#include <Stepper.h>
#include <SD.h>

const int stepsPerRevolution = 1500;

Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);

int IRpin = 0;
#define RED 1
#define GREEN 2

LiquidCrystal lcd (3, 4, 5, 6, 7, 13);

IRrecv irrecv(IRpin);
decode_results results;

void translateIR()

{
  switch(results.value)


{
  case 0xFFA25D: Serial.println("POWER"); break;
  case 0xFFE21D: Serial.println("FUNC/STOP"); break;
  case 0xFF629D: Serial.println("VOL+"); break;
  case 0xFF22DD: Serial.println("FAST BACK");    break;
  case 0xFF02FD: Serial.println("PAUSE");    break;
  case 0xFFC23D: Serial.println("FAST FORWARD");   break;
  case 0xFFE01F: Serial.println("DOWN");    break;
  case 0xFFA857: Serial.println("VOL-");    break;
  case 0xFF906F: Serial.println("UP");    break;
  case 0xFF9867: Serial.println("EQ");    break;
  case 0xFFB04F: Serial.println("ST/REPT");    break;
  case 0xFF6897: lcd.print("0");    break;
  case 0xFF30CF: lcd.print("1");    break;
  case 0xFF18E7: lcd.print("2");    break;
  case 0xFF7A85: lcd.print("3");    break;
  case 0xFF10EF: lcd.print("4");    break;
  case 0xFF38C7: lcd.print("5");    break;
  case 0xFF5AA5: lcd.print("6");    break;
  case 0xFF42BD: lcd.print("7");    break;
  case 0xFF4AB5: lcd.print("8");    break;
  case 0xFF52AD: lcd.print("9");    break;
  case 0xFFFFFFFF: Serial.print(" REPEAT");break;  

  default: 
    Serial.println(" other button   ");

}

delay(500);
}

void setup()
{
  lcd.begin(16, 2);


  Serial.begin(9600);
  Serial.println("IR Receiver Button Decode");
  irrecv.enableIRIn();
pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  digitalWrite(RED, HIGH);

  myStepper.setSpeed(20);
  }

void loop()
{
  if (irrecv.decode(&results))

  {
    translateIR();
    irrecv.resume();
  }

  int PinNum = digitalRead(IRpin);



lcd.setCursor(0, 0);

lcd.print("Locked     ");

if (results.value == 0xFF18E7)
 {
  lcd.setCursor(0,0);
  lcd.println("Unlocked         ");
  delay (1000);
  digitalWrite(RED, LOW);
  digitalWrite(GREEN, HIGH);
  myStepper.step(1040);
  return;
  
 }
  else
  {
  digitalWrite(GREEN, LOW);
  digitalWrite(RED, HIGH);
 }
lcd.setCursor(0, 1);

lcd.print ("Enter Pin");

lcd.setCursor(10, 1);

}

You need a variable to keep track of whether the motor has moved - something like

if (motorMoved == false) {
   // code to make the motor move
   motorMoved = true;
}

...R

  int PinNum = digitalRead(IRpin);

It hardly makes any sense to do a digitalRead() on the IR receiver's pin. You'll learn NOTHING. Storing the state of the pin in a variable called PinNum makes no sense, either.

If you press a button on the IR, there is a value stored in the value field of the struct instance named results. If you put the remote down, the value in results.value never changes. So, your motor will move when you press the button. Then, it will move again when you do nothing. Then, it will move again when you do nothing. Then, it will move again when you do nothing. Then, it will move again when you do nothing.

If you explicitly set results.value to 0 after moving the motor, then next time through loop, results.value will not trigger the motor to move again.