Ghusl When The Time Is Running Out
If a ghusl is required then it should be performed before offering the salat.