You cannot control exchanges in any way, so there is nothing that can be done about hack attacks on them.
The solution to this problem could be refraining from storing huge amounts of coins on exchanges (though I know it is not always possible and coins have to be there for at least several days).
I concur. Leaving a very small amount of coins in an exchange, would protect you from losing it all in the case of a hack. But, if you're looking to trade large amounts of cryptocurrency within various days, then it's not the most feasible option. I think that you'd be safe doing your trades in a decentralized exchange as it's much safer than centralized counterparts. A decentralized exchange doesn't rely on a central operator, company, or individual, and it's distributed across many computers around the world.
For a hacker to penetrate a decentralized exchange, it'll take a lot of hard work and effort just like hacking a cryptocurrency like Bitcoin. My preferred choice is Bitshares as a decentralized exchange for most of my crypto trades and it's extremely secure, fast, and dirt cheap. It's a client-side system as your keys are never stored in the DEX. Only you have access to the private key to safely store your crypto assets or trade them without the fear of hacks, censorship or downtime.
In the case of using a cryptocurrency for your daily transactions, I'd recommend that you use a hardware wallet as it's the safest option available now. The Ledger Nano S supports most cryptocurrencies, but there are other options that are quite handy too. My personal favorite is the CoolWallet S hardware wallet as it's very slim in a size of a credit card, and it easily fits into your physical wallet. It supports many popular cryptocurrencies, but not all of them. Hence, if you're looking for a hardware wallet that would allow you to safely store or send most cryptocurrencies, then the Ledger Nano S would be your best bet. But if you're looking for convenience and extreme portability (with the downside that not many cryptocurrencies are supported) then the CoolWallet S would be ideal for you.
All in all, cryptocurrencies will as safe as you want them to be. Following the best practices to secure your private keys would be crucial towards protecting your funds from being hacked by anyone.