Fix resource leak in create_pid_file().
Fix buffer overrun.
Fix resource leak.
Explicitly return NULL or 0 on M_ABORT error.

This makes the work for static analyzing tools a lot easier that
don't understand that a M_ABORT means stop executing the program
and abort creating a crash on our way out.