Bugfixes

UDP socket was not always closed.