Short version
Use a named pipe.
openssl aes-256-cbc -a -salt -in twitterpost.txt -out foo.enc -pass file:<( echo -n "someGoodPassword" )
Long version
Use a named pipe. You can create it in bash with
<( *output* )
e.g.
<( echo -n "content" ) # without -n echo will add a newline
It will open a named pipe, usually a FIFO queue, and you will see on the process list something like
/dev/fd/63
It will be readable only by the current user and will be automatically closed after it has been read, so you don't have to worry about permissions and cleaning up the disk (the pipe would close if the program crash, while a file created by you as suggested in another answer would stay on disk).
This way it will close in the fastest way possible, just after the command read it and without waiting for it to finish his task (I just did a test: encrypt some gigabytes and try to read the named pipe (it's visible in the process list): the named pipe closes instantaneously even if openssl takes ages to encrypt).
About your comments
If the computer has been compromised by a 2nd app to obtain this
password, then the user has some serious security issues to worry
about. Actually, it could be some software specifically designed to
attack my own software
If your computer has been hacked and the attacker has your same user rights, you're done for. At example the attacker may easily modify your .bashrc to alias openssl so that it starts an hypotetic "evil-openssl" that copy your password and data before handling everything to the real openssl, leaving you with your false sense of security.
That said, I'm not a security expert, so if anyone want to downvote me into oblivion (and tell me why), you're welcome.