Since, window size is 5, all first 5 packets will be sent continuously. After receiving acknowledgements, window will be slided. When timeout occurs, entire window will be retransmitted again.
12345
[45678] - 4th packet in previous transmission is lost. When timeout occurs, window will be like this. So, this window is retransmitted as below.
[45678] - 8th packet loss in previous transmission will be ignored as expected ack is for 4th packet.
[78910] - 7th packet in previous transmission is lost. When timeout occurs, window will be like this. So, this entire window is retransmitted.
[78910] - Again 7th packet in previous transmission is lost.
[78910]
[78910]...
The last window will be in transmission forever. So question is wrong.