fix pidfile_context to remove the pidfile on exceptions