Added an explicit close to the serial connection