Properly clean up manager resources on exit