Upload by serial and debug using JTAG don't sharer port well

Platfromio newbie, hopefully this is easy:

I’m debugging an esp32 with the FTDI jtag, but using the serial upload.

upload_protocol = esptool
debug_tool = esp-prog
debug_init_break = tbreak setup

Between debug sessions, plafrom.io does not know to close the monitor port so that it can upload, so I get this permission error. If I close the monitor port first it works fine.

raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))

serial.serialutil.SerialException: could not open port 'COM4': PermissionError(13, 'Access is denied.', None, 5)

*** [upload] Error 1

Is there a way to automate closing the monitor to avoid this error?

Turns out there is supposed to be a feature for this, but it does not work correctly for the debugger.