properly reset terminal after server exits