I'd like to join James in welcoming you here.
HYour husband has a great deal gong on in his life right now, with stress over future employment, pain, medications a change in lifestyle and more.
Acting in a manner that direly causes you stress, particularly as it is not typical of how he was before, could be a combination of one or more of these factors, including the medication.
Like James may I suggest you go have a long talk with whoever is responsible for his medical team, perhaps though not always, his GP. Although you may not be able to ask about things there is nothing to stop you saying in details what is happening
To this end I'd keep a diary so you have concrete instances to show. This may have unexpected benefits, such as it being a set period after taking a medication or some other pattern.
I would also suggest that you need support yourself right now.
Trying to live on the shifting grounds of such behavior, crying, thinking of extreme methods of relief, which I suspect means you are thinking of ending your life, and having these periods of depression are all very much danger signals you have reached the end of your theater.
It is easy to assume you can always care for a loved one, but there are limits and you have reached yours. Such serious problems as your partner has need a team, not just one person..
Apart from personal medical support do you have anyone, family or friend, you can lean on right now>? It can make a big difference. When I became extremely ill my wife had her mum to help, both practically and emotionally, and that was a blessing.
You know you are welcome here anytime