Things like this is why I use XFS anywhere I'm not using btrfs, or ZFS.
The reason I stay with ext4 is that it has proven amazingly robust in the event of hard reboots.
Some reading if you're not familiar with sysrq: https://en.wikipedia.org/wiki/Magic_SysRq_key Depending on your distro you might have to enable it, I believe ubuntu (for some dumb reason) ships with emergency sync as the only command available.
Enabling it should amount to adding: kernel.sysrq=1 to /etc/sysctl.conf on older machines or editing /etc/sysctl.d/10-magic-sysrq.conf on newer ones.
also if you are running out of ram that often you might want to consider a swap partition. Or if you have one already try setting a more aggressive swapiness value.