Fix shutdown process
Fix and add tests