@Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        if(skip) {
            return;
        }

        if (this.executeStopOnVMShutdown) {
            this.executeStopOnVMShutdown = false;
           if (!invokedTogetherWithDockerStart()) {
                throw new MojoExecutionException("docker:stop with executeStopOnVMShutdown is only possible if" +
                        " the docker containers started within the same maven session.");
            }

            try {
                // HttpDelete class is not used during start mojo, so we need to load it and initialize it. It is not
                // possible to load classes in the shutdown hook as
                Class.forName("org.apache.http.client.methods.HttpDelete", true, this.getClass().getClassLoader());

                // com.google.common.base.Strings class from com.google.guava is required and it depends on Platforms
                // Used in @see io.fabric8.maven.docker.util.ImageNameFormatter
                Class.forName("com.google.common.base.Strings", true, this.getClass().getClassLoader());
                Class.forName("com.google.common.base.Platform", true, this.getClass().getClassLoader());
            } catch (ClassNotFoundException e) {
                log.error("Failure in loading org.apache.http.client.methods.HttpDelete class: %s", e.getMessage());
            }

            Runtime.getRuntime().addShutdownHook(new Thread(() -> {
                try {
                    super.execute();
                } catch (MojoExecutionException | MojoFailureException e) {
                    log.error("Failure in stopping container: %s", e.getMessage());
                }
            }));
        } else {
            super.execute();
        }
    }
If true, the containers are not stopped right away, but when the build is finished (success or failed).
src/main/java/io/fabric8/maven/docker/StopMojo.java