I had a similar requirement recently. Not the nicest solution in some ways, but what I did was setup a virtual motion sensor and add it to a Zone Motion Controller setup (a built-in HE App, you could use others if you wish). In your case when the switch turns off, setup a small rule to activate the virtual motion sensor. I also configured the sensor to have a short timeout, so soon after the switch is turned off, the trigger to turn off the lights in RL will kick in. It won't turn off the lights immediately, but will allow motion shortly after to keep the lights on.