fixed cleanup on exit