Android is a pretty secure OS for the most part which Google is constantly working to make more secure, but it still faces issues with malware. In the background, Google has quietly introduced a "panic mode" that helps protect users from situations like these.
The idea behind "panic mode" is to provide the user a guaranteed way to get out of any rogue application and bring them back to the homescreen.
When Android detects that, it overrides whatever application is open and causing the problem, delivering the user to their homescreen where they can uninstall the rogue app. It seems likely that, for now, Google hasn't finished this application and plans to enable it by default in future versions of the OS.