Terminate the app middleware