Reset variables when connection is closed