How to end sending data over I2C by Slave or Master?
But I wonder how does this handshaking takes place between a Master and Slave when the Slave is sender and the Master is receiver and only the Slave (sender) knows when there is no more data to send to the receiver?


This isn't supposed to happen. i2c is a very defined protocol and each slave device should be known to each master. Typically, the master requests the slave to transmit, and either the message size is fixed, the message is sequential, or the message includes how many bytes will be sent.


Master writes a register address, then master switches to read and the slave sends a byte. That's all the master wants, sends a stop.
Master writes a register address, then master switches to read and the slave sends a byte, then the master reads again, so the slave sends the next byte (or same byte). The master reads how ever many it wants, arbitrarily, then sends a stop.
Master writes a register address, then master switches to read and the slave sends a byte. That byte tells the master how many bytes that register should have. Master reads and slave sends that many, then master stops.


All communication is controlled by the master. The slave does nothing the master doesn't want it to do. The master controls the speed of the clock (clock stretching not withstanding) and how many bytes are read. At no time should the slave try forcing the data line when the master did not tell it to. The data structure should be known before hand.