Job hangs when BUILDKITE_PTY is true

When I run brakeman the job just hangs when is ready to print the report.
This is only happening when running via buildkite. Even if I do a docker exec on the same container where brakeman is hanging, and run it from there, brakeman works fine. It only hangs when running via the buildkite agent.

The only way to make it work was by setting BUILDKITE_PTY=false in the pipeline definition.