drop root privileges only after creating all listening sockets

and ensure releasing all memory if failing to switch user and exiting the program
(even if not strictly necessary ... it's still something good to do)