fixed a small bug with terminal not being reset under circumstances