Add waitForActivityStackToBeEmpty method

Enables a test to wait for all activities to finish.