Prevent apps from opening in context of other apps
Apps can launch other apps' activities inside their task. This makes
  it impossible to switch back and forth between the two.


In that case you may use an Xposed module ActivityForceNewTask (You need   Xposed Framework installed as well as root)

This module sets the FLAG_ACTIVITY_NEW_TASK flag when starting a new activity, which 'fixes' that.

It basically forces activities launched within applications to create a new task, allowing for much easier switching between the two. In this case if you click on a GitHub link from Yahoo Mail, the GitHub browser app is not opened within Yahoo Mail but as a seperate task with its own window, and it's separately closeable.



Here is an illustration, showing how the module addresses the problem in  question:


Credits: https://forum.xda-developers.com/xposed/modules/mod-activityforcenewtask-t2646504