properly cleaning up on halt