fixed so that ports are always closed after running