Fixed termination bug. Ends cleanly now.