Waiting before leaving page. Fixes #743