A brief introduction to this problem:
STM32F7 is configured for USB Device FS. USB interface is used to transmit a large array of data from MCU to computer. If, by any chance user closes the Virtual Com Port of MCU, next time user opens com port, MCU will send remains of the data it was transmitting to computer, creating a lot of troubles.
I want to flush TX buffer of USB Device mode or abort transmition progress whenever VCP is opened/closed in the computer.