P-channel or N-channel MOSFET configuration for safety circuit cutoff
You're doing it the hard way (even ignoring a bunch of craziness and nonsense in your schematic, like shorting the power rails through two switches), because it's really annoying to control a FET in series with a load (the motor) where the voltage is all over the place because of the H-bridge.

The right answer is to leave the motor directly connected to the H-bridge and to control the H-bridge inputs using the limit switches.

What H-bridge are you using?  Its control scheme (ENABLE+DIR?  FWD/REV?) will change how you wire it up.  You don't want to completely disable the motor when an end-stop is hit, you just want to prevent it from continuing in the same direction.

You say "H Bridge Relay", so I'll draw it as a pair of relays:







simulate this circuit &ndash; Schematic created using CircuitLab

With this schematic, the motor will be idle by default, will run one way when FWD is pulled up, and will run the other way when REV is pulled up (connect these wires to microcontroller outputs).  If you pull them both up, it will stop.

SW3 and SW4 are your limit switches.  Each one, when open, prevents the motor from running in one direction.  The motor can still run in the other direction though, to allow it to come away from the stops.

If your bridge is something else (some FETs controlled by some fancy silicon?) the control scheme will differ, but the desire is the same: each limit switch prevents the motor from running in a particular direction.

Edit: I see you've posted the H-bridge model number now.  It's mechanical therefore too slow for PWM, but it's also wired pretty much like I've drawn it above, with opto-isolators in place of the transistors I've shown.

If your limit switches are wired together and have only two terminals present, then you can't tell which switch has been hit, so you can't easily make a safe-in-hardware system.  You would need to keep track in software of which direction the motor is running and monitor the limit switch in software.  The software would be responsible for deducing from the motor-direction which limit switch was hit, and if it goes wrong (or the software crashes), your motor will crash into its hard stops.

If your limit switches have a common connection (3 pins), then it's doable like this:







simulate this circuit

The conjugate with NPN transistors would also work but it's less obvious which limit switch affects which end.  Either way, you will need to do some testing+experimenting to make sure that things go in the direction you expect and stop in the correct directions.