A one year contract won't affect UC claimed when the contract ends.
Giving up permanent work for temporary and claiming 2wks later when you're no longer needed? That's not going to look good and they'll possibly deem you voluntarily unemployed so you'll get nothing.
The way to deal with your situation is to go sick, long term if necessary. You'll get SSP at least even if your employer doesn't pay your wages, don't know if you could also get housing benefit etc (does that even cover mortgages?), I expect you'd be entitled to some form of help if yours is the only wage and your sickness is long term. It wouldn't be worth claiming for a 3wk sickness for example, you'd be back at work before the money came through.
If your employment is ended by the employer on medical grounds, you move onto UC and it's not deemed your fault you're unemployed. Depending on how sick you are you could look for another job whilst on sick leave. If it's the job making you ill taking that positive action could make you feel better as well as securing a new job sooner.
If yours is the second wage and you could theoretically manage without it or with only half of it, then agency work isn't a bad idea in the circumstances. You can't put a price on your health. You'd need to budget though and work out the minimum you need to live on, save the rest and if there's money for a treat now and then that's good and if there isn't never mind. If you do this, only ever spend half the savings so you've got some emergency money left. Don't live like a king when you've got work and put it all on a credit card when you're between jobs, that's the road to disaster. You can make your agency work a second wage by finding something part time but permanent to cover the basics.