I know it’s a poor solution, but there is a button to set the interior lights not to come on when the doors are considered to be opened if I remember correctly. It should be near your left knee on the dashboard I think.
And if you want to fix this for good, you are in for a thorough investigation with a multimeter along the electric lines leading to the switch or sensor that is supposed to send a signal with the tailgate opens. Nissan’s sensors are crap after certain number of years, they send random unpredictable signals. I had hell of a hard time with an older Maxima that would stall at random and restart itself at random too. Was a bad switch.