It looks like EclipseLink is closing the connection before the shutdown hook executes. (I am not 100% sure but from my experiments it looks that way.) I need to do something inside the shutdown hook, so I need to prevent EclipseLink to close the connection. As an example for clarification, in Log4j I can do it using this directive in the XML config file:
<Configuration shutdownHook="disable">
Is there something like this for EclipseLink?