cleanup of main activity loop