Ok taking the softner wont be the cause of this. As it takes the softner at the very end of the cycle so if its playing up during the cycle then you find it wont take the softner. If its working fine but not taking softner then its just a blocked dispenser unit thats casuing this. So for the time being ingorne the softner fault as this wont causing the fault you have. And may be making you think its something to do with the softner fill when it isnt.
As its spinning and filling ok then you are looking at either a faulty wash heater or the control board. As there isnt much inside a washer. You have water valves, heater, motor and pump and pressure switch. As it sometimes work then you can rule the water valves and pressure switch out.
And when it fails it does drain and spin then again you can rule the motor and pump out as well.
So this leaves the wash heater or the control board. As if a heater fails it can cause faults later on in the cycle and can be intermitten as well. What you need to do is check the heater with a multi meter and see if faulty. The heater is loacted either in the front of the drum or the back depending on the model. So remove the back panel first and see if the heaters there. If not then you need to remove the front panel to access the heater.
It should read about 28 Ohms. If faulty then you need to replace the heater and see how it goes from there.
But if the heater is fine then you are looking at a faulty control board which will need to be replaced to cure this. Then it should sort the softner filling from there.
If its still not taking softner at the end of the cycle then you need to give the dispenser roof inside were the drawer goes a good clean out.