added a cleanup function to pidfile