private void stopContainers(QueryService queryService, RunService runService, GavLabel gavLabel)
            throws MojoExecutionException, IOException, ExecException {

        Collection<Network> networksToRemove = getNetworksToRemove(queryService, gavLabel);
		List<DockerAccessException> thrownExceptions = new ArrayList<>();
        for (ImageConfiguration image : getResolvedImages()) {

            Collection<Container> existingContainers
                    = getContainersForImage(queryService, image);

            for (Container container : existingContainers) {
                if (shouldStopContainer(container, gavLabel)) {
					try {
						runService.stopContainer(container.getId(), image, keepContainer, removeVolumes);
					} catch (DockerAccessException exc) {
						thrownExceptions.add(exc);
					}
                }
            }
        }
        // If the mojo has a stopNamePattern, check to see if there are matching containers
        for (Container container : getContainersForMojo(queryService)) {
            if (shouldStopContainer(container, gavLabel)) {
            	try {
	                runService.stopContainer(container.getId(),
	                        new ImageConfiguration.Builder().name(container.getImage()).build(),
	                        keepContainer, removeVolumes);
            	} catch (DockerAccessException exc) {
					thrownExceptions.add(exc);
				}
            }
        }

		try {
			runService.removeCustomNetworks(networksToRemove);
		} catch (DockerAccessException exc) {
			thrownExceptions.add(exc);
		}

		if (!thrownExceptions.isEmpty()) {
			DockerAccessException exception = new DockerAccessException("At least one exception thrown during container removal.");
			for (DockerAccessException dae : thrownExceptions) {
				exception.addSuppressed(dae);
			}
			throw exception;
		}
    }
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