Does the OS kills resource hungry process automatically if the battery becomes low I am running virtual box with 2 VMs using MacBook Pro(macOS Sierra). I noticed that the virtualbox is killed whenever the battery charge becomes very less(~ 4%). 

Does the OS kills it due to low battery or its just a correlation happening by chance after seeing it a few times.
The OS does have the ability to send warnings (essentially allow apps to subscribe to warnings) for low memory or low power so they may save their state or throttle down processing.  

The OS doesn't kill processes, but instead goes to sleep or hibernation. 

I suppose vbox could implement this, but my suspicion is that it's only coincidence.