“Run” will indeed erase and flash and verify and optionally reset the target.
Maybe the stlink stay in debug swd mode.
It shouldn’t as the shutdown command is invoked at the end and we exit swd mode normally.
Or maybe your “Debug” config is letting something different than in “Release” config.
Can you try to set “Release” config and “Run” again to see if any difference ?