Dear Carlos Candido,
One of the things I would like to mention it’s the fact that in the USB communication the host it’s the one in charge of managing the devices and descriptors; for that reason, the device cannot perform a detach by itself.
The host it’s who can send a BUS RESET command to the reset of the end devices; in any case of a disconnection or reset the re-enumeration can’t be left behind, it will always need to re-enumerate the device.
One approach it’s to add a transistor in the VBUS connection, as the D+ / D- lines resistors are hung up to them, this transistor will be controlled by a GPIO acting as a switch by doing this the host will acknowledge this as a detach.
Best Regards,
Estephania