Onan 4000 Service Manual
here. Page 10-2 has a diagram that shows the location of the oil level switch. The instructions on the same page say to remove the oil pan from the engine to gain access to the switch, which is inside the pan. Looks like quite a bit of dis-assembly is required to get to the oil pan.
Also the table on page 6-9 lists several reasons other than the oil level switch which would cause the engine to stop when the switch is released.
On page 6-6 is a wiring diagram that shows that pin 7 on the P1 connector from the control board is connected to the oil level switch. The other side of the switch connects to ground. A continuity test between pin 7 and ground will indicate whether the switch is open or closed. I assume that normal oil level closes the switch, but don't know for sure. If the oil is at the proper level per the dipstick, you can test the switch by draining the oil. If the switch is supposed to be closed for normal oil level, it should be open for low oil. On the other hand, if the switch is supposed to be open for normal oil level, it should be closed for low oil. If the switch doesn't change when the oil is drained, then the switch is defective.