Why mosfet doesn't turn off when battery voltage is low?
Are you really using an RH1028 opamp?  It is completely unsuitable - it doesnlt work off 5v.

In particular you need one that can bring the output down to the negative rail.

Something cheap and simple such as an LM324/LM358 would be suitable.

You also cannot connect the positive power rail to the same point as the negative input.  You can power the opamp directly from the 18v rail.

The negative opamp supply needs to come directly from the ground - currently you are switching off the opamp and asking that its output pin go below its ground pin. Even when the opamp output is as low as it can go it will still be at the same potential as the drain of the FET.

Also because you have the negative side of your reference LDO connected to the FET as soon as the FET turns off the LDO and the negative input to the opamp will float towards the +18v rail - it will be difficult to turn on again even if the battery goes above 5v.

That will mean you cannot switch off the power to the opamp.

Overall this circuit will not work well and needs rethinking.

Drive the FET gate from a PNP transistor that in turn is driven from the opamp (need to correct polarity).  Put a resistor from the gate to ground.  When the PNP turns off so will the FET,even if there is 18v across the transistor the current can still be extremely low (sub microamp).