Hi Mateuz,
This looks like the slave is getting stuck in some point, I will suggest to check the if the baud rate and write/read timing is between the spec.
Also check with some logic analyzer in which moment the transmission is getting stuck, maybe you could aisle the issue and identify is in a respective command.
One workaround for this is to use a timeout, one way to do this is to check if the stop condition is not reached between a certain time, change the multiplexing of the SCK to a GPIO and toggle this pin until the slave release the lines.
Let me know if this helps you
Best Regards,
Alexis Andalon