How can I run an STM32L with an unpowered ST-Link connected?
Option 1:  Disconnect NRST pin from the debug connector on target board. Works okay for me. Unless you do not use sleep modes, it should be fine. Be ready for very rare need of Power Resets still.  

Option 2: Use a analog Switch to cut all the JTAG and NRST lines when you don't need them to the connected to the target. When you power the hub there are ways to enable this analog Switch (or Buffer) and when you remove the hub, it can get automatically disabled. Disabling the buffer (or Analog Switch) will keep boh target and STLINK isolated.   


  my firmware is largely based on FreeRTOS. A software solution would be ideal if someone can suggest how to do that.


Not a good idea because, this will become a case of dog trying to bite its tail case.  

Further worked solution from OP:  

had to change the stm32l4discovery.cfg file from "reset_config srst_only" to "reset_config srst_nogate