512Ending Phase

The ending phase consists of two steps: end and cleanup.