This fixes #13551
From perldoc perlobj:
The order in which objects are destroyed during the global destruction
before the program exits is unpredictable. This means that any objects
contained by your object may already have been destroyed. You should
check that a contained object is defined before calling a method on it.
The current version of Test::PostgreSQL uses Moo and stores the File::Temp directory as an attribute. When the File::Temp directory is defined, it uses postmaster stop command. When the directory is undef, it tries to do its own flawed shutdown. During global destruction (when the perl program exits) the order in which things are destroyed is undefined, so the File::Temp directory gets destroyed first hence triggering the alternative postgres shutdown.