added @atexit function to automagically remove pidfile