How can I make the code stop when a specific button is pressed?

function delay() does what its name says

delaying (everything) until the delay() has finished.
This means as long as the delay() is "active" no other line of code can be executed.

For your wanted functionality of stop the pump with a button you use a "software"-switch
almost the same way as you would use an elctromechanical switch.
switch "ON" machine/pump/lamp "active"
switch "OFF" machine/pump/lamp "INactive"

inside code such a software-"switch" is coded by an if-condition

the basic principle looks like this

boolean pumpActive;

void loop() {
  if (pumpActive == true) {
    // execute code that makes the pump run
  }

  if (digitalRead(myStopButton_Pin == pressed) {
    pumpActive = false
  }
  

The button must be checked all the time = many times per second
This means you can't use delay

The same applies if you want to use an IR-remote
You must check all the time = many times per second if a new remote-command was sended

You have to use non-blocking timing which is as one example explained here

I'm very interested in beginners questions to improve my tutorials.
So feel free to ask as much as you want.

To have a minmal number of if-conditions you can use a programming-tecnique called state-machine.
Which is explained here

best regards Stefan