How do I run a function in a process and afterwards terminate the process?

Suppose I have the module Amodule containing a function:

module Amodule

function twice(x)
  2 .* x


I need to run Amodule.twice on a worker process that I terminate afterward from another module:

module Bmodule

using Distributed

@everywhere include("Amodule.jl")
@everywhere using Main.Amodule

function test(x)
  pid = addprocs(1)[1]

  F = @spawnat pid Main.Amodule.twice(x)
  M = fetch( F )
  rmprocs( workers()... )

  all( M .== 2 .* x)



ERROR: LoadError: On worker 2:
UndefVarError: Bmodule not defined

How do we correct the Bmodule so that the test function can create a worker process, run Amodule.twice(x), and then kill it?

Even if I replace the remote call with a trivial

F = @spawnat pid 1+1

the worker fails when it tries to find Bmodule.

I guess I do not understand the semantics of @spawnat. The child process does not inherit the context of the parent? How can I inform the child process about the Bmodule within the Bmodule?