Added some fail-safe code to remove socket file.