Is there a method that guarantees dying in hospital and being relevant for organ donor?
Yes. A car accident, drug overdose, or something catastrophic like major CVA (stroke). I'm sure there are more, I just can't think of any right now.
Ideally, the donor will be brain dead with a beating heart, and kept on life support to maintain homeostasis; this is why death needs to happen in a hospital setting.
Patients who die in the hospital but are not on a life support can, in some circumstances, donate their kidneys, and in certain circumstances, other organs; this applies to donors that have a heartbeat. Both heartbeating and non-heartbeating donors can donate their corneas and other tissue.